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 |
谁也帮我看看吧,谢谢辣#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator