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 Godshit at 2014-12-13 15:28:56 on Problem 1006
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main()
{
	
	int p,e,i,d,a,b,c;
	
	for(int k=1;k;k++)
	{
		cin>>p>>e>>i>>d;
		if(p==-1&&e==-1&&i==-1&&d==-1)  //判断结束
			break;

		//标识peak的起始时间
		a=p;
		b=e;
		c=i;
		
	
		//抽象化所有特殊情况,即给的d那一天刚好是3个circle的peak同一天时,进行处理
		if(abs(p-d)%23==0&&abs(e-d)%28==0&&abs(i-d)%33==0)
		{
			p++;
			e++;
			i++;
			d=1;
		}
		else //一般情况下
		{
			p=e=i=d;  //各个circle从d那一天开始进行处理
			d=0;   //d=0,省去对21252的求余处理,重新计数
		}
	

		
		while(abs(p-a)%23!=0||abs(e-b)%28!=0||abs(i-c)%33!=0) //判断3个circle的peak是否在同一天,否,则所有天数+1
		{
			p++;
			e++;
			i++;
			d++;
		}
		
		//不输出p,e,i,不需要对他们进行处理,d前面置0,即为所求天数
		cout<<"Case "<<k<<": the next triple peak occurs in "<<d<<" days."<<endl;
	}

		

	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