Search found 2 matches

by Adnan_Sarker
Wed Jul 29, 2015 4:05 pm
Forum: Volume 129 (12900-12999)
Topic: 12908 - The book thief
Replies: 4
Views: 1073

Re: 12908 - The book thief

Yes i got it. its a realy so nice & simple problem. oj give me TLE using for cin && cout.
by the way, i got ac :wink:
by Adnan_Sarker
Tue Jul 28, 2015 11:36 pm
Forum: Volume 129 (12900-12999)
Topic: 12908 - The book thief
Replies: 4
Views: 1073

12908 - The book thief (Getting TLE)

i am getting TLE with this code, can anyone tell me why i get TLE ? i LL n,ans,mp,p,an,N,NN; while(cin>>n) { if(n==0){return 0;} NN=n*2; ans=sqrt(NN); N=ans+5; for(int i=ans;i<=N;i++) { an=(i*(i+1))/2; if(an>=n){p=i; mp=an-n; break;} } if(mp==0){p=p+1; mp=((p*(p+1))/2)-n;} cout<<mp<<" "<<p<<endl; }

Go to advanced search