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 |
我狠笨,所以用笨方法……0MS过#include<iostream> int main() { int a[1501]; a[1]=1; int p2=1,p3=1,p5=1; for(int i=2;i<=1500;i++) { int *x; int min=1000000000; int c2=a[p2]*2,c3=a[p3]*3,c5=a[p5]*5; if(min>c2){min=c2;x=&p2;} if(min>c3){min=c3;x=&p3;} if(min>c5){min=c5;x=&p5;} a[i]=min; (*x)++; while(a[p2]*2<=a[i])p2++; while(a[p3]*3<=a[i])p3++; while(a[p5]*5<=a[i])p5++; } int n; while(scanf("%d",&n)&&n)printf("%d\n",a[n]); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator