为甚么16年Qingdao Online 都是暴力题emm///。。。
先暴力预处理
然后lower _bound二分
#include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <cmath> #define rap(i, a, n) for(int i=a; i<=n; i++) #define rep(i, a, n) for(int i=a; i<n; i++) #define lap(i, a, n) for(int i=n; i>=a; i--) #define lep(i, a, n) for(int i=n; i>a; i--) #define rd(a) scanf("%d", &a) #define rlld(a) scanf("%lld", &a) #define rc(a) scanf("%c", &a) #define rs(a) scanf("%s", a) #define MOD 2018 #define LL long long #define ULL unsigned long long #define Pair pair<int, int> #define mem(a, b) memset(a, b, sizeof(a)) #define _ ios_base::sync_with_stdio(0),cin.tie(0) //freopen("1.txt", "r", stdin); using namespace std; const int maxn = 10010, INF = 0x7fffffff; LL sum[maxn], cnt; LL inv(LL a, LL b) { LL res = 1; while(b) { if(b & 1) res = res * a; a = a * a; b >>= 1; } return res; } void init() { rep(i, 0, 30) { int f1 = 0; rep(j, 0, 30) { int f2 = 0; rep(k, 0, 30) { int f3 = 0; rep(m, 0, 30) { LL res = 1; res *= inv(2, i); if(res > 1e9) { f1 = 1; break; } res *= inv(3, j); if(res > 1e9) { f2 = 1; break; } res *= inv(5, k); if(res > 1e9) { f3 = 1; break; } res *= inv(7, m); if(res > 1e9) break; sum[cnt++] = res; } if(f3) break; } if(f2) break; } if(f1) break; } } int main() { cnt = 0; init(); sort(sum, sum + maxn); int T; rd(T); while(T--) { LL n; rlld(n); int res = lower_bound(sum, sum + maxn, n) - sum; printf("%lld ", sum[res]); } return 0; }