NC25716. Trial of Devil
描述
输入描述
The first line contains an integer number T, the number of test cases.
of each next T lines contains one integer n(
), the number of sequence.
输出描述
For each test case print a number, the minimum number of operations required.
示例1
输入:
2 1 2
输出:
1 2
C++14(g++5.4) 解法, 执行用时: 3ms, 内存消耗: 484K, 提交时间: 2019-05-12 13:03:32
#include<bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); printf("%d\n", (int)(log2(n)) + 1); } }
C++11(clang++ 3.9) 解法, 执行用时: 3ms, 内存消耗: 352K, 提交时间: 2019-05-12 12:49:45
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--){ int x; cin>>x; cout<<int(log(x)/log(2))+1<<endl; } return 0; }
Python3(3.5.2) 解法, 执行用时: 35ms, 内存消耗: 3548K, 提交时间: 2020-04-29 12:53:27
T=int(input()) for i in range(T): ans=0 n=int(input()) while n: ans+=1 n//=2 print(ans)