POJ-1006(中国剩余定理)
2014-08-21 21:11
183 查看
http://poj.org/problem?id=1006
中国剩余定理:
先求出
X1%23==1,X1%28==0,X1%33==0;
X2%28==1,X2%23==0,X2%33==0;
X3%33==1,X3%28==0,X3%23==0;
代码如下:
得:X1=5544, X2=14421,X3=1288
故:所求天数为 N=5544×p+14421*e+1288*i-d;
代码如下:
中国剩余定理:
先求出
X1%23==1,X1%28==0,X1%33==0;
X2%28==1,X2%23==0,X2%33==0;
X3%33==1,X3%28==0,X3%23==0;
代码如下:
#include<stdio.h> int main() { int i; for(i=1;i<100;++i) if((28*33)*i%23==1) break; printf("%d\n",(28*33)*i); for(i=1;i<100;++i) if((23*33)*i%28==1) break; printf("%d\n",(23*33)*i); for(i=1;i<100;++i) if((23*28)*i%33==1) break; printf("%d\n",(23*28)*i); while(1); return 0; }
得:X1=5544, X2=14421,X3=1288
故:所求天数为 N=5544×p+14421*e+1288*i-d;
代码如下:
#include<stdio.h> int main() { int p,e,i,d,k=0; while(scanf("%d%d%d%d",&p,&e,&i,&d),!(p==-1&&e==-1&&i==-1&&d==-1)) { k++; int m=(5544*p+14421*e+1288*i-d+21252)%21252; if(m<=0) printf("Case %d: the next triple peak occurs in %d days.\n",k,21252+m); else printf("Case %d: the next triple peak occurs in %d days.\n",k,m); } return 0; }
相关文章推荐
- POJ 1006 与中国剩余定理
- Poj 1006 生理周期(中国剩余定理)
- POJ 1006(中国剩余定理)
- POJ 1006 Biorhythnms(中国剩余定理)
- poj 1006 Biorhythms (中国剩余定理模板)
- POJ 1006 Biorhythms(中国剩余定理)
- poj1006 / hdu1370 Biorhythms (中国剩余定理)
- POJ 1006 Biorhythms (中国剩余定理)
- poj 1006 Biorhythms(中国剩余定理)
- Poj 1006 生理周期(中国剩余定理)
- POJ 1006 Biorhythms(中国剩余定理)
- POJ_1006_Biorhythms(中国剩余定理)
- poj 1006 生理周期(中国剩余定理)
- POJ 1006 Biorhythms (中国剩余定理)
- POJ 1006-Biorhythms(中国剩余定理)
- POJ 1006 Biorhythms(中国剩余定理)
- POJ 1006 Biorhythms (中国剩余定理)
- POJ 1006 Biorhythms(中国剩余定理)
- POJ 1006 Biorhythms 解题报告(中国剩余定理)
- poj 1006(中国剩余定理)