标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 767 Accepted Submission(s): 403
#include <cstdio> #include <algorithm> #define ll long long using namespace std; ll a[10000]; void get(int n) { a[0] = 1; int n2 = 0; int n3 = 0; int n5 = 0; int n7 = 0; int cnt = 1; while(cnt < n){ ll t1 = min(a[n2]*2, a[n3]*3); ll t2 = min(a[n5]*5, a[n7]*7); ll t = min(t1, t2); if(t == a[n2]*2) ++n2; if(t == a[n3]*3) ++n3; if(t == a[n5]*5) ++n5; if(t == a[n7]*7) ++n7; a[cnt++] = t; } } int main() { get(5200); int t, n; scanf("%d", &t); while(t--){ scanf("%d", &n); printf("%I64d\n", *lower_bound(a, a+5219, n)); } return 0; }
标签:
原文地址:http://www.cnblogs.com/inmoonlight/p/5893885.html