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 |
我是跳着数数的 居然47ms过了 之前不知道剩余定理#include"iostream" using namespace std; int main() { int p,e,i,d; int count=1; int n,k; while(1) { int flag=1; scanf("%d%d%d%d",&p,&e,&i,&d); if(p==-1&&e==-1&&i==-1&&d==-1) break; for(n=1;n<=23;n++) if((n-p)%23==0) break; for(n;n<=667;n+=23) if((n-e)%28==0) break; for(n;n<=21252;n+=644) if((n-i)%33==0) { flag=0; if(n<=d) k=n-d+21252; else k=n-d; printf("Case %d: the next triple peak occurs in %d days.\n",count++,k); break; } if(flag) { if(d==21252)k=21252; else d=21252-d; printf("Case %d: the next triple peak occurs in %d days.\n",count++,k); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator