首页 > 其他 > 详细

POJ1006、hdu1370

时间:2018-02-17 12:03:37      阅读:252      评论:0      收藏:0      [点我收藏+]

思路:中国剩余定理。纯粹的用暴力求逆元。

 1 #include<iostream>
 2 #include<string.h>
 3 #include<string>
 4 #include<algorithm>
 5 #include<stdio.h>
 6 #include<iomanip>
 7 #include<cmath>
 8 #include<map>
 9 using namespace std;
10 void Find(int &x,int &y,int &z){
11     while(23*28*x%33!=1){
12         x++;
13     }
14     while(23*33*y%28!=1){
15         y++;
16     }
17     while(28*33*z%23!=1){
18         z++;
19     }
20 }
21 int main(){
22     int x,y,z;
23     x=y=z=1;
24     Find(x,y,z);
25     int p,e,i,d,times;
26     times=1;
27     //int T;
28     //cin>>T;  //hdu需要多这两行
29     while(cin>>p>>e>>i>>d){
30         if(p==-1&&e==-1&&i==-1&&d==-1){
31             break;
32         }
33         int ans=(z*33*28*p+y*23*33*e+x*23*28*i-d+23*28*33)%(28*23*33);
34         if(ans==0) ans=28*23*33;
35         cout<<"Case "<<times++<<": the next triple peak occurs in "<<ans<<" days."<<endl;
36     }
37     return 0;
38 }

 

POJ1006、hdu1370

原文:https://www.cnblogs.com/ISGuXing/p/8451532.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!