poj 1006 剩余定理
来源:互联网 发布:网络动漫城 编辑:程序博客网 时间:2024/06/06 06:41
无脑套板子….
好像不需要理解什么意思的样子….
具体就是知道余数(除数积/当前)(除数积/当前 mod当前的逆元)求和….
就可以了…
板子有学长写好的…
#include<iostream>#include<algorithm>#include<cmath>#include<string>#include<cstdio>using namespace std;long long a[3],m[3],n;void ex_gcd(int a, int b, int &x, int &y) //板子 { if (!b) { x = 1; y = 0; return; } ex_gcd(b, a%b, y, x); y -= (a / b) * x;}long long CRT()//板子 { long long M = 1; long long ans = 0; for (int i = 0; i < n; i++)M *= m[i]; for (int i = 0; i < n; i++) { int x, y; long long t = M / m[i]; ex_gcd(t, m[i], x, y); ans += a[i] * t * x; ans %= M; } ans = (ans + M) % M; return ans;}int main(){ int q,w,e,r; n=3; m[0]=23,m[1]=28,m[2]=33; int u=0; while(cin>>q>>w>>e>>r) { if(q==-1)break; a[0]=q,a[1]=w,a[2]=e; long long i=CRT()-r; if(i<=0)i+=21252; printf("Case %d: the next triple peak occurs in %lld days.\n",++u,i); } return 0;}
0 0
- poj 1006 剩余定理
- poj 1006 剩余定理
- POJ 1006 中国剩余定理
- POJ 1006 中国剩余定理
- POJ 1006 中国剩余定理
- 中国剩余定理POJ 1006
- POJ 1006 ( 中国剩余定理 )
- POJ-1006(中国剩余定理)
- poj 1006-中国剩余定理
- poj 1006 中国剩余定理
- POJ 1006 中国剩余定理
- Poj 1006 中国剩余定理
- POJ 1006 中国剩余定理
- poj 1006 中国剩余定理
- poj-1006 中国剩余定理
- POJ 1006 中国剩余定理
- poj 1006 中国剩余定理
- POJ 1006: 中国剩余定理
- 图解Android Studio导入Eclipse项目源码
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- 轻量级图形报表工具JSCharts (JSChart),内置函数中文参考及中文解决方案
- 实验3:android数据储存和访问----登录记住密码功能
- B-Tree
- poj 1006 剩余定理
- opengles TEXTURE__2D and GL_TEXTURE_EXTERNAL_OES
- mac eclipse tomcat 配置 安装
- 警示名言整理
- linux shell脚本案例二
- 串口
- 学习之路
- 机器视觉开源处理库汇总
- 【Android】修改Tablayout中标签文字的样式