Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

G++程序 Sample过了 why wa? 清高手指点

Posted by xuezaiyue at 2005-08-29 16:25:57 on Problem 2545
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator