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 wyylling at 2009-09-15 16:14:08 on Problem 1006 and last updated at 2009-10-24 09:40:58
#include <cstdio>

#include <iostream>

#include<string>



using namespace std;



int main(int argc, char* argv[])

{

	int ph,em,in,d;

	//next peak

	int next;

	int total;

	int count = 1;

	while(true)

	{

		cin>>ph>>em>>in>>d;

		if( (ph == -1) && (em == -1) && (in == -1) && (d == -1))

			break;

		next = 1;

		total = next;

		while(total <= 21252 )

		{

			total = d + next;

			if( (total -ph <= 0) && (total - em <= 0) && (total - in <= 0))

			{

				next++;

				continue;

			}

			if( (total - ph) % 23 == 0)

				if( (total - em) % 28 == 0)

					if( (total - in) % 33 == 0)

					{
						next += 21252;
						next %= 21252;
						if(next == 0) next = 21252;

						cout<<"Case "<<count<<": the next triple peak occurs in "<<next<<" days."<<endl;

						break;

					}

					next++;

		}

		count++;

	}

	return 0;

}

//////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
	int ph,em,in,d;
	int next;
	int total;
	int count = 1;
	while(true)
	{
		cin>>ph>>em>>in>>d;

		if( (ph == -1) && (em == -1) && (in == -1) && (d == -1))
			break;
		next = 1;
		total = next;

		//while(total <= 21252 )
		while(true)
		{
			total = d + next;
			if( (total -ph <= 0) && (total - em <= 0) && (total - in <= 0))
			{
				next++;
				continue;
			}

			if( ((total - ph) % 23 == 0) && ((total - em) % 28 == 0) && ((total - in) % 33 == 0))
			{
				next += 21252;
				next %= 21252;
				if(next == 0) next = 21252;
				cout<<"Case "<<count<<": the next triple peak occurs in "<<next<<" days."<<endl;
				break;
			}
			next++;
		}
		count++;
	}
	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