首页 > 代码库 > Poj 1006
Poj 1006
就是中国剩余定理的应用……
幸好我学了数学基础
1 #include<iostream> 2 using namespace std; 3 int main(){ 4 int p,e,i,d; 5 int k; 6 int count=1; 7 while(cin>>p>>e>>i>>d){ 8 if(p==-1&&e==-1&&i==-1&&d==-1){ 9 break; 10 } 11 k=0; 12 p=p%23; 13 e=e%28; 14 i=i%33; 15 k=(k+(p*5544))%21252; 16 k=(k+(e*14421))%21252; 17 k=(k+(i*1288))%21252; 18 if(k==0){ 19 k+=21252; 20 } 21 if(d==k){ 22 cout<<"Case "<<count<<": the next triple peak occurs in "<<21252<<" days."<<endl; 23 } 24 else if(k>d){ 25 cout<<"Case "<<count<<": the next triple peak occurs in "<<k-d<<" days."<<endl; 26 } 27 else{ 28 cout<<"Case "<<count<<": the next triple peak occurs in "<<k-d+21252<<" days."<<endl; 29 } 30 count++; 31 } 32 }
Poj 1006
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。