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 wcw at 2008-04-01 17:14:55 on Problem 1006
下面是我他通过的程序,其中
if ( ( result[n] - e ) % 28 == 0 && ( result[n] - p ) % 23 == 0 ){
//if ( result[n] % 28 == e && result[n] % 23 == p ){
这两行我实在是看不出区别,后者用:
283 102 23 320
通不过,好像陷入死循环了。好请高人指教。


#include <stdio.h>

int
main( ){
	int n = 0;
	int p, e, i, given;
	int count = 1;
	int result[1000];
	
	while( 1 ){
		scanf( "%d%d%d%d", &p, &e, &i, &given );
		if( p == -1 || e == -1 || i == -1 || given == -1 ){
			break;
		}
		while( 1 ){
		
			result[n] = count * 33 + i;
			if ( ( result[n] - e ) % 28 == 0 && ( result[n] - p ) % 23 == 0 ){
		//	if ( result[n] % 28 == e && result[n] % 23 == p ){
				result[n] -= given;
				if( result[n] > 21252 ){
					result[n] -= 21252;
				}
				count = 1;
				printf( "%d\n", result[n]);
				break;
			}
			
			count++;
		}
		n++;
	}
	for( i = 0; i < n; i++ ){
		printf( "Case %d: the next triple peak occurs in %d days.\n", i + 1, result[i] );
	}
	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