poj1006:Biorhythms(中国剩余定理,扩展欧几里得)
来源:互联网 发布:淘宝全球购靠谱吗 编辑:程序博客网 时间:2024/05/22 19:27
传送门
题意:
给定四个数a,b,c,d。求满足
的最小正整数M。
题解:
又是一道板题。
设
同理求得
则
最小取个
#include<cstdio>using namespace std;int A,B,C,bg;long long a,b,ans;inline void exgcd(int x,int y,long long &a,long long &b){ if(!y) { a=1; b=0; return; } exgcd(y,x%y,a,b); long long a2=a; a=b; b=(a2-b*(x/y));}int main(){ while(scanf("%d%d%d%d",&A,&B,&C,&bg),A!=-1,B!=-1,C!=-1,bg!=-1) { static int tt=0; ++tt; ans=0; exgcd(23*28,33,a,b); a*=C; a=(a%33+33)%33; ans+=a*23*28; exgcd(28*33,23,a,b); a*=A a=(a%23+23)%23;; ans+=a*28*33; exgcd(23*33,28,a,b); a*=B; a=(a%28+28)%28; ans+=a*23*33; ans%=21252; if(bg>=ans)ans+=((bg-ans)/21252+1)*21252; printf("Case %d: the next triple peak occurs in %lld days.\n",tt,ans-bg); }}
阅读全文
0 0
- poj1006:Biorhythms(中国剩余定理,扩展欧几里得)
- poj1006 扩展欧几里得算法+中国剩余定理
- Biorhythms(poj1006+中国剩余定理)
- 20160321 POJ1006 Biorhythms (中国剩余定理)
- poj1006 Biorhythms(中国剩余定理)
- [POJ1006]Biorhythms(中国剩余定理)
- [POJ1006]Biorhythms(中国剩余定理)
- poj1006 Biorhythms(中国剩余定理)
- POJ1006-Biorhythms .中国剩余定理
- Poj1006 Biorhythms (中国剩余定理)
- Biorhythms(poj1006中国剩余定理)
- poj1006 Biorhythms 中国剩余定理
- POJ1006 - Biorhythms - 中国剩余定理
- POJ1006 Biorhythms 中国剩余定理
- POJ1006 Biorhythms【中国剩余定理】
- POJ1006 Biorhythms(中国剩余定理)
- poj1006 Biorhythms中国剩余定理
- poj1006--Biorhythms (中国剩余定理)
- 小结
- 【模板】并查集
- 趣题学算法之栈及其应用-Web导航
- 关于Qt设计师中相关设置问题
- 计算特殊数字
- poj1006:Biorhythms(中国剩余定理,扩展欧几里得)
- jquery中unbind和bind的用法
- 如何将区块链技术应用到物联网
- Html5中的a标签详解
- haoi2014贴海报解题报告
- Java实训课5
- 集合Collection
- BZOJ[1196][HNOI2006]公路修建问题 二分+并查集
- ajax请求成功之后控制页面刷新一次