`
mycream
  • 浏览: 54225 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

POJ 1006 Biorhythms

 
阅读更多

POJ 1006 Biorhythms

这题是去年完成的,找了下当时的代码,用C完成的。其原理就是“中国剩余定理”,故具体内容不解释。见代码如下:

#include <stdio.h>
int main() {
  int p, e, i, d, a, t = 1;
  while(1) {
    scanf("%d%d%d%d", &p, &e, &i, &d);
    if (-1 == p && -1 == e && -1 == i && -1 == d)
      break;

    a = (5544 * p + 14421 * e + 1288 * i - d + 21252) % 21252;
    if (!a)
      a = 21252;

    printf("Case %d: the next triple peak occurs in %d days.\n", t, a);
    t++;
  }
  return 0;
}
 
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics