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 |
G++程序 Sample过了 why wa? 清高手指点#include <cstdio> long long num[4000000]; long long i,p1,p2,p3,n,m1,m2,m3; main() { while(scanf("%lld%lld%lld%lld",&p1,&p2,&p3,&n)!=EOF) { num[0]=1; m1=0; m2=0; m3=0; if(n>4000000) while(1); for(i=1;i<=n;i++) { if(num[m1]*p1<num[m2]*p2 && num[m1]*p1<num[m3]*p3) { num[i]=num[m1]*p1; m1++; } else if(num[m2]*p2<num[m1]*p1 && num[m2]*p2<num[m3]*p3) { num[i]=num[m2]*p2; m2++; } else if(num[m3]*p3<num[m1]*p1 && num[m3]*p3<num[m2]*p2) { num[i]=num[m3]*p3; m3++; } else if(num[m2]*p2==num[m1]*p1 && num[m2]*p2<num[m3]*p3) { num[i]=num[m2]*p2; m2++; m1++; } else if(num[m2]*p2<num[m1]*p1 && num[m2]*p2==num[m3]*p3) { num[i]=num[m2]*p2; m2++; m3++; } else if(num[m1]*p1<num[m2]*p2 && num[m1]*p1==num[m3]*p3) { num[i]=num[m1]*p1; m3++; m1++; } else if(num[m2]*p2==num[m1]*p1 && num[m2]*p2==num[m3]*p3) { num[i]=num[m2]*p2; m2++; m1++; m3++; } } printf("%lld\n",num[n]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator