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

为啥用例全通过了,却Ac不了???

Posted by 200593141 at 2007-05-23 18:46:31 on Problem 1006
/* C++ */

#include<iostream>

using namespace std ;

int triple_peak( int, int, int, int ) ; 

int main()
{
   int counter = 1 ;

   int p = 0, e = 0, i = 0, d = 0 ;

   while( cin >> p >> e >> i >> d )
   {
      if( p == -1 && e == -1 && i == -1 && d == -1 )
		  break ;
	  cout << "Case " << counter++ 
	       << ": the next triple peak occurs in "
	       <<  triple_peak( p % 23, e % 28, i % 33, d ) << " days.\n" ;
   
   }

   return 0 ;
}


int triple_peak( int p, int e, int i, int d )
{
	int e_p = ( e - p + 28 ) % 28 ;

	int i_p = ( i - p + 33 ) % 33 ;

	int e_p_n = 0 ;

	int i_p_n = 0 ;

	for( int counter = 1 ; counter <= 28 ; counter++ )
		if( (23 * counter) % 28 == e_p )
			break ;

		e_p_n = counter ;

    for( counter = 1 ; counter <= 33 ; counter++ )
		if( (23 * counter) % 33 == i_p )
			break ;

		i_p_n = counter ;

	int i_e = ( i_p_n - e_p_n + 33 ) % 33 ;

	for( counter = 1 ; counter <= 33 ; counter++ )
		if( (28 * counter) % 33 == i_e )
			break ;  
	
	return  23 * ( 28 * counter + e_p_n ) + p - d ;
}

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