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

我把数组的大小改成了300,这次成了WA...代码很短 ,能否看看……

Posted by Ceoalpha at 2006-03-24 20:22:37
In Reply To:你怎么不说所有的题都用100?! Posted by:frkstyc at 2006-03-24 20:14:48
#include<iostream>
using namespace std;

int max(int i, int j)
	{
		if(i>=j)
			return i;
		else return j;
	}

void main()
{
	int p[300],e[300],i[300],d[300];
	int ans;
	int day;
	int cnt=0;
	bool flag=true;
	while(flag)
	{
		cin>>p[cnt]>>e[cnt]>>i[cnt]>>d[cnt];
		if(p[cnt]==-1 && e[cnt]==-1 && i[cnt]==-1 && d[cnt]==-1)
			flag=false;
		cnt++;
	}

	for(int j=0;j<cnt-1;j++)
	{
		day=p[j];
		flag=true;
		for(int k = max(max(max(p[j],e[j]), i[j])+1, 23); ;k++) 
		{
			if(((k - p[j])%23 == (k - e[j])%28) && ((k-p[j])%23 == (k-i[j]) % 33)) {
				day=k;
				break;
			}
		}

		ans=day-d[j];
		cout<<"Case "<<j+1<<": the next triple peak occurs in "<<ans<<" days."<<endl;
	}
}

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