Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
ac了,但是有很多疑问,可以在你们的机器上帮我测下吗?下面是我他通过的程序,其中 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator