jeudi 9 mars 2017

how do i reduce time limit for my code.The calculation time is more

this is the solution to question(http://ift.tt/2hcrcLR).The solution is working good for small numbers but for large numbers it's taking more time.

#include<iostream>
using namespace std;
typedef unsigned long long ll;
int main()
{
int t;cin>>t;
ll n,m,s;
while(t!=0)
{
    cin>>n>>m>>s;
    while(m!=0)
    {
        if(s<=n)
        {
            s++;
        }
        if(s>n)
        {
            s=1;
        }
        m--;
    }
    t--;
    cout<<s-1<<endl;
  }
 }

Aucun commentaire:

Enregistrer un commentaire