|
|
вернуться в форумtime exceeded。。can you help me make it faster? Послано xinxin 16 сен 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? Послано Said 15 май 2020 04:21 #pragma optimize( "g", on ) |
|
|