Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
终于搞定,虽然做完感觉简单但还是收获不少。#include<iostream> using namespace std; int min(int a,int b,int c) { int m; if(a>=b) m = b; else m=a; if(m>=c) m=c; return m; } int main() { int set[1505]; set[1] = 1; int t1=1; int t2=1; int t3=1; for(int i=2;i<=1500;i++) { int temp = min(set[t1]*2,set[t2]*3,set[t3]*5); if(temp == set[t1]*2) t1++; if(temp == set[t2]*3) t2++; if(temp == set[t3]*5) t3++; set[i] = temp; } int nums; while(cin>>nums&&nums) { cout<<set[nums]<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator