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 | #include<iostream> using namespace std; int fun_1(int x,int y){ long long res = 0,t = 1; while(t<=x/y){ res++; t*=y; } return res; } int fun_2(int y){ long long l=0,r=y,mid; while(l<r){ mid = (l+r+1)/2; if(mid>y/mid){ r = mid-1; } else{ l = mid; } } return l; } int main(){ int a,b; cin >> a >> b; cout << fun_1( a , b ) << " "; cout << fun_1( fun_2(a) , b ); return 0; } |
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)
1、若输入为“63 2”,那么输出的第一个数字为 5
2、若将第 22 行的 l 改为 mid,那么程序结果一定会变。
3. 若输入的 a 为 b^4(2<=b<=200),那么输出的第一行一定是第二行的两倍。
4. 若输入为“1024 4”,那么输出结果为( )
5. 输入为“282 3”,那么输出结果为( )
6. fun_1()和 fun_2()的时间复杂度分别为( )