POJ 1006 Biorhythms
来源:互联网 发布:手机隐形定位软件 编辑:程序博客网 时间:2024/06/11 15:12
中国剩余定理,学习了..
具体的定理讲起来可能难以理解,百度一下就可以了..这里举个小例子吧..
比如 x%3=1,x%4=2.x%5=4,求x的最小值,分别求两两最小公倍数(4,5)=20,(3,5)=15,(3,4)=12,三者公倍数(3,4,5)=60..
现在就是使20,15,12分别乘以某个数使他们模3,4,5的值相同.
因此有20*2%3=1,15*3%4=1,12*3%5=1..然后40*3+45*4+36*5=274
因为比60大,所以274-60*4=34,即为所求数..
#include <stdio.h>//(23,28)=644 1288%33=1//(23,33)=759 14421%28=1//(28,33)=924 5544%23=1//(23,28,33)=21252int main(){int a,b,c,d,i=1;while(scanf("%d%d%d%d",&a,&b,&c,&d)){if(a==-1&&b==-1&&c==-1&&d==-1)break;int res=(1288*c+14421*b+5544*a+21252-d)%21252;if(res==0)res=21252;printf("Case %d: the next triple peak occurs in %d days.\n",i++,res);}}
- poj 1006 Biorhythms
- poj 1006 Biorhythms
- poj 1006 Biorhythms
- POJ 1006 Biorhythms
- POJ 1006 Biorhythms
- POJ 1006 Biorhythms
- 【POJ】1006 Biorhythms
- POJ-1006:Biorhythms
- POJ 1006 Biorhythms
- POJ 1006 Biorhythms
- POJ 1006 Biorhythms
- poj 1006 Biorhythms
- POJ 1006 Biorhythms
- Poj 1006 Biorhythms
- POJ 1006 Biorhythms
- poj 1006 hdu1370 Biorhythms
- 【POJ】1006 Biorhythms
- poj 1006 Biorhythms
- SqlParameter序列化的问题 (报错: 由于安全限制,无法访问类型 System.Runtime.Remoting.ObjRef)
- Jakarta-ORO
- 继承及内存分析
- ADF中调用JavaScript的方法
- WPF实现拖拽方法
- POJ 1006 Biorhythms
- 说得有理。。。
- strcmp
- 系统崩溃造成数据库无法启动的恢复
- 经纬度1秒约等于多少米?
- ERROR: ORA-28002: 7 天之后口令将过期
- itoa函数及atoi函数
- HBase Compression
- 如何汉化 po 文件及编译成 mo 文件