1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <iostream> using namespace std; long long n, ans; int k, len; long long d[1000000]; int main() { cin>>n>>k; d[0]=0; len=1; ans=0; for (long long i = 0; i < n; i++) { ++d[0]; for (int j = 0; j+1 < len; ++j){ if(d[j]==k){ d[j]=0; d[j+1]+=1; ++ans; } } if(d[len-1]==k){ d[len-1]=0; d[len]=1; ++len; ++ans; } } cout<<ans<<endl; return 0; } |
假设输入的 n是不超过 262 的正整数,k 都是不超过 10000 的正整数。
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
若k=1,则输出ans时,len=n。
2.若k>1,则输出ans时,len一定小于n。
3.若k>1,则输出ans时,一定大于n。
4.若输入的n等于,输入的k为1,则输出等于( )
5.若输入的等于205,891,132,094,649(即),输入的k为3,则输出等于()
6.若输入的n等于100,010,002,000,090,输入的k为10,则输出等于( )