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

120K 32MS 比较和谐的暴力破解……

Posted by PhoeniXszx at 2012-03-12 23:13:50 on Problem 1006
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <ctype.h>
//#include <math.h>

#define DP 23
#define DE 28 
#define DI 33

int main( void )
{
   int n = 1;
   int p , e , i , d ;

   //freopen( "in.txt" , "r" , stdin );
   //freopen( "out.txt" , "w" , stdout );

   for( scanf( "%d%d%d%d" , &p , &e , &i , &d ) ; p != -1 ; scanf( "%d%d%d%d" , &p , &e , &i , &d ) )
   {
      //get interval
      p = ( p - d ) % DP ,  e = ( e - d ) % DE ,  i = ( i - d ) % DI ;
      //in case interval below 0
      p += ( p < 0 ? DP : 0 ),  e +=( e < 0 ? DE : 0), i +=( i < 0 ? DI : 0);
      if( p == e && p == i )
      {
         printf( "Case %d: the next triple peak occurs in %d days.\n" , n++ , (p == 0) ? 21252 : p );
         continue;
      }
      while( p != e || p != i )
      {
         p += 23;
         if( p - e >= 5 )
            e += 28;
         if( e - i >= 5 )
            i += 33;
      }
      printf( "Case %d: the next triple peak occurs in %d days.\n" , n++ , p );
   }

   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