|
|
вернуться в форумОбщий форум1131 I get timelimit error what should I do ? any better algo ?! #include<iostream> #include<stdio.h> #include<math.h> using namespace std; int main() { int n,k; char line[100]; scanf("%s",line); n=atoi(line); scanf("%s",line); k=atoi(line); int power=1; int h=1; int sum=2; if(k>=(n/2)) { while(pow(2,h)<n) h++; } else { while(sum<=k) { sum*=2; h++; } while(sum<=n) { sum+=k; h++; }
} cout<<h; return 0; } |
|
|