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

一直是wa,请大家帮忙看一下,所有的数据都测试通过了!

Posted by 198939 at 2011-04-08 17:21:49 on Problem 1006
刚开始做ACM,写的有点笨,见谅哈!所有的测试数据都测试过了,依旧是WA,苦恼中!
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int minimum(int a,int b,int c)
{
	int temp=366;
	if(a<temp)
		temp=a;
	if(b<temp)
		temp=b;
	if(c<temp)
		temp=c;

	return temp;
}

int main()
{
    vector<int> data;
	int p,e,i,d;
        while(true)
	{
	    cin>>p;cin>>e;cin>>i;cin>>d;
	    if((p==-1)&&(e==-1)&&(i==-1)&&(d==-1))
		  break;
            data.push_back(p);
            data.push_back(e);
            data.push_back(i);
            data.push_back(d);
	}//读入数据

	for(int m=0;m<data.size();m=m+4)
	{
                 p=data.at(m);
		 e=data.at(m+1);
		 i=data.at(m+2);
		 d=data.at(m+3);
 		 
		 int min=minimum(p,e,i);
		 bool flag=false;
		 for(int x=0;x<min;x++)
		 {
			 int px=(p-x)%23;
			 int ex=(e-x)%28;
			 int ix=(i-x)%33;

			 if((px==0)&&(ex==0)&&(ix==0))
			 {
				 if(x>d)
				     cout<<"Case "<<(m+4)/4<<": the next triple peak occurs in "<<x-d<<" days."<<endl;
				 else
			             cout<<"Case "<<(m+4)/4<<": the next triple peak occurs in "<<21252+x-d<<" days."<<endl;
				 flag=true;
			 }

		 }
                 if(!flag)
		 {	
			 for(int n=min;n<21252+366;n++)
			 {
				 int pt=abs(n-p)%23;
				 int et=abs(n-e)%28;
				 int it=abs(n-i)%33;
                                 bool logo=false;
				 if((n-p==0)||(n-e==0)||(n-i==0))
				 {
					 if((pt==et)&&(et==it)&&(pt==0))
                                         {
					    if(n>d)
				               cout<<"Case "<<(m+4)/4<<": the next triple peak occurs in "<<n-d<<" days."<<endl;
					    else
				               cout<<"Case "<<(m+4)/4<<": the next triple peak occurs in "<<21252+n-d<<" days."<<endl;

						break;

					 }
					 logo=true;
				 }

				 if((!logo)&&(pt==et)&&(et==it)&&((abs(n-p))/23>0)&&((abs(n-e))/23 > 0)&&((abs(n-i))/23 > 0))
				 {
					 if(n>d)
				             cout<<"Case "<<(m+4)/4<<": the next triple peak occurs in "<<n-d<<" days."<<endl;
					 else
				             cout<<"Case "<<(m+4)/4<<": the next triple peak occurs in "<<21252+n-d<<" days."<<endl;

					 break;
				 }
			 }
			 
		 }
	}

	return 1;
}

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