首页 > 编程语言 > 详细

中国剩余定理算法详解 + POJ 1006 Biorhythms 生理周期

时间:2018-07-22 19:51:13      阅读:203      评论:0      收藏:0      [点我收藏+]

转载请注明出处:http://exp-blog.com/2018/06/24/pid-1054/

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 int main()
 5 {
 6     int p,e,i,d,n=0;
 7     while (scanf("%d %d %d %d",&p,&e,&i,&d))
 8     {
 9         if (p==-1&&e==-1&&i==-1&&d==-1)//记得出口!!!
10         {
11             break;
12         }
13         n++;
14         p=p%23;//找第一个高峰期
15         e=e%28;
16         i=i%33;
17         int j;
18         for (j=i;;j+=33)
19         {
20             if (j%23==p&&j%28==e&&i%33==i&&j>d)
21             {
22                 printf("Case %d: the next triple peak occurs in %d days.\n",n,j-d);
23                 break;
24             }
25         }
26     }
27 
28     return 0;
29 }

 

中国剩余定理算法详解 + POJ 1006 Biorhythms 生理周期

原文:https://www.cnblogs.com/hemeiwolong/p/9351093.html

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