POJ 1006 Biorhythms 生理周期 中国剩余定理
2016-10-19 19:39
239 查看
链接 : POJ 1006 Biorhythms
中文: POJ 1006 生理周期
我通过 ζёСяêτ - 小優YoU 的博客学习, 不再赘述。
不过貌似有点错误, 应该是33 * 28 * x0 (=6) == 5544 吧……
我的代码:
中文: POJ 1006 生理周期
我通过 ζёСяêτ - 小優YoU 的博客学习, 不再赘述。
不过貌似有点错误, 应该是33 * 28 * x0 (=6) == 5544 吧……
我的代码:
#include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; int main() { int p, e, i, d; int cas = 0; while(cin >> p >> e >> i >> d) { if(p == -1 && e == -1 && i == -1 && d == -1) break; cas ++; int lcm = 23*28*33; int n = (5544*p+14421*e+1288*i-d+lcm)%lcm; if(n == 0) n = lcm; printf("Case %d: the next triple peak occurs in %d days.\n", cas, n); } return 0; } /* 已知(n+d)%23=p; (n+d)%28=e; (n+d)%33=i 使33×28×a被23除余1,用33×28×**8**=5544; 使23×33×b被28除余1,用23×33×19=14421; 使23×28×c被33除余1,用23×28×2=1288。 因此有(5544×p+14421×e+1288×i)% lcm(23,28,33) =n+d 又23、28、33互质,即lcm(23,28,33)= 21252; 所以有n=(5544×p+14421×e+1288×i-d)%21252 */
相关文章推荐
- POJ 1006:Biorhythms 中国剩余定理
- POJ 1006 Biorhythms | 中国剩余定理
- POJ 1006:Biorhythms 中国剩余定理
- POJ1006-Biorhythms .中国剩余定理
- poj 1006 Biorhythms (中国剩余定理学习)
- POJ 1006/ ZOJ 1160: Biorhythms - 中国剩余定理
- POJ 1006 Biorhythms 【中国剩余定理】
- POJ 1006 Biorhythms (数论-中国剩余定理)
- POJ1006: 中国剩余定理的完美演绎
- poj 1006 Biorhythms 中国剩余定理
- 每日ACM小题--POJ1006——中国剩余定理的完美诠释 2013年11月04(附录POJ_1005水题一枚)
- 中国剩余定理小结 (互质,非互质) (poj 1006,hdu 3579)
- poj 1006 中国剩余定理
- POJ 1006: 中国剩余定理
- POJ 1006 中国剩余定理
- POJ 1006 Biorhythms【中国剩余定理】
- poj 1006 Biorhythms 中国剩余定理
- poj 1006 中国剩余定理模板
- POJ 1006 Biorhythms [中国剩余定理]
- POJ 1006 中国剩余定理