标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 21453 | Accepted: 9586 |
Description
Input
Output
Sample Input
1 2 9 0
Sample Output
1 2 10
Source
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<cstdlib> #include<algorithm> #include<queue> #include<vector> #include<stack> using namespace std; int n,ans[1505]; int main() { ans[1]=1; int p1=1,p2=1,p3=1; for(int i=2;i<=1500;i++) { ans[i]=min(ans[p1]*2,min(ans[p2]*3,ans[p3]*5)); if(ans[i]==ans[p1]*2) p1++; if(ans[i]==ans[p2]*3) p2++; if(ans[i]==ans[p3]*5) p3++; } while(scanf("%d",&n)!=EOF) { if(n==0) break; printf("%d\n",ans[n]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4394288.html