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

直接模拟过!贴下代码!

Posted by nothing828 at 2010-04-02 21:17:56 on Problem 1006
#include<iostream>
using namespace std;

int peak[3];
int day[22000];
int move[3]={23,28,33};

int main()
{
	int d,i,j,cases=0;
	while(scanf("%d%d%d%d",&peak[0],&peak[1],&peak[2],&d) && peak[0]!=-1)
	{
		memset(day,0,sizeof(day));
		for(i=0;i<3;i++)
		{
			peak[i]%=move[i];
			day[peak[i]]++;
		}
		for(i=1;i<1500;i++)
			for(j=0;j<3;j++)
				if(peak[j]+i*move[j]-d<=21252)
					day[peak[j]+i*move[j]]++;
		for(i=0;i<=21252+d;i++)
			if(day[i]==3 && i>d)
			{
				printf("Case %d: the next triple peak occurs in %d days.\n",++cases,i-d);
				break;
			}
	}
	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