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

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

Posted by fluke at 2006-02-20 16:16:33 on Problem 2545
In Reply To:G++程序 Sample过了 why wa? 清高手指点 Posted by:xuezaiyue at 2005-08-29 16:25:57
#include <cstdio>

long long num[2010];
long long p1, p2, p3, n;
int i, 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>2001)
            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]);
				if(num[n] > 1000000000)
					printf("%d%09d\n", (int)(num[n] / 1000000000), (int)(num[n] % 1000000000));
				else
					printf("%d\n", (int)(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