NC54665. lglg说要有题,于是便有了题。
描述
输入描述
第一行输入一个 T (t<=1e4)
接下来每行一个正整数n,用来描述题意中的那个n (1<= n <= 3*1e8)。
输出描述
对于每一个输入需要输出一个ans,对于答案保留整数。
本题没有SPJ,请采用如下方式输出以保证和出题人答案一致。
输出方式
printf("%.0lf")
示例1
输入:
3 2 4 280
输出:
0 1 2
Python3(3.5.2) 解法, 执行用时: 92ms, 内存消耗: 3540K, 提交时间: 2019-11-17 14:39:36
import math t=int(input()) for tt in range(t): n=int(input()) if n==2 or n==1: print(0) elif n<=28: print(1) elif n<=11788: print(2) elif n<=9000000: print(3) else: ans=math.log(math.log(n)) print("%.0f"%ans)
C++11(clang++ 3.9) 解法, 执行用时: 4ms, 内存消耗: 352K, 提交时间: 2019-11-17 14:32:52
#include<bits/stdc++.h> using namespace std; int t, n; int main() { scanf("%d", &t); while(t-- > 0) { scanf("%d", &n); if(n < 3) puts("0"); else if(n < 29) puts("1"); else if(n < 11789) puts("2"); else puts("3"); } }
C++14(g++5.4) 解法, 执行用时: 34ms, 内存消耗: 524K, 提交时间: 2019-11-25 20:23:39
#include<bits/stdc++.h> #define ll long long using namespace std; int main() { int q;cin>>q; while(q--){ ll n;cin>>n; if(n<3)cout<<"0\n"; else if(n<29)cout<<"1\n"; else if(n<11789)cout<<"2\n"; else cout<<"3\n"; } return 0; }
C(clang11) 解法, 执行用时: 4ms, 内存消耗: 224K, 提交时间: 2021-03-02 13:21:43
#include<stdio.h> int main() { int t,n; scanf("%d",&t); for(;t;t--) { scanf("%d",&n); if(n<3) printf("0\n"); else if(n<29) printf("1\n"); else if(n<11789) printf("2\n"); else printf("3\n"); } }