|
|
back to boardtime exceeded。。can you help me make it faster? Posted by xinxin 16 Sep 2016 19:06 #include<stdio.h> #include<math.h> int main() { int n,k,i=1,s=1,t=0,temp=0; scanf("%d %d",&n,&k);
while(i<k) { s=s+i; i=2*i; t++;
if(s>=n) break; } while(s<n) { s=s+k; t++; } printf("%d",t); return 0; } Re: time exceeded。。can you help me make it faster? while(s<n) { s=s+k; t++; } Isn't here (n-s)/k iterations? Re: time exceeded。。can you help me make it faster? Posted by Said 15 May 2020 04:21 #pragma optimize( "g", on ) |
|
|