码迷,mamicode.com
首页 > 其他好文 > 详细

Poj 1006

时间:2017-01-25 21:20:52      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:poj   bsp   include   rip   pac   blog   str   ace   triple   

就是中国剩余定理的应用……

幸好我学了数学基础

 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

标签:poj   bsp   include   rip   pac   blog   str   ace   triple   

原文地址:http://www.cnblogs.com/marlenemizuno/p/6349998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!