中国剩余定理 poj1006
来源:互联网 发布:迪杰斯特拉算法 编辑:程序博客网 时间:2024/05/01 11:37
http://poj.org/problem?id=1006
裸的中国剩余定理
x=a1mod(b1)
x=a2mod(b2)
x=a3mod(b3)
只需要求x1=a1*a2*i 使得a1*a2*i%a3==b3 等x2 x3 最后(x1+x2+x3)% lcm(x1,x2,x3)
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>#include <set>#include <map>#include <vector>#include <queue>#include <fstream>#include <math.h>#include <iomanip>using namespace std;typedef long long ll;typedef pair<int,int> Pii;const int INF=0x7fffffff;int main(){ int x,y,z,d,cs=1; while(cin>>x>>y>>z>>d){if(x==-1&&y==-1&&z==-1&&d==-1) break;x%=23;y%=28;z%=33;ll xx,yy,zz;for(int i=1;;i++){if(28*33*i%23==x) {xx=28*33*i;break;}}for(int i=1;;i++){if(33*23*i%28==y){yy=33*23*i;break;}}for(int i=1;;i++){if(28*23*i%33==z) {zz=28*23*i;break;}}ll t=xx+yy+zz-d+(23*28*33); t%=23*28*33;if(t==0) t+=23*28*33;printf("Case %d: the next triple peak occurs in %I64d days.\n",cs++,t); } return 0;}
0 0
- POJ1006 中国剩余定理
- poj1006--中国剩余定理
- POJ1006 中国剩余定理
- poj1006中国剩余定理
- poj1006 中国剩余定理
- poj1006中国剩余定理
- poj1006中国剩余定理
- POJ1006: 中国剩余定理
- poj1006(中国剩余定理)
- poj1006 中国剩余定理
- 中国剩余定理 poj1006
- POJ1006|中国剩余定理
- poj1006中国剩余定理
- 中国剩余定理 poj1006
- POJ1006中国剩余定理
- 中国剩余定理poj1006
- nyoj151/poj1006中国剩余定理
- 中国剩余定理(韩信点兵)POJ1006
- Coco2d-js/Cocos2d-html5中Android返回键实现
- Kmeans聚类算法-二维度数组(Java实现)
- 网页语法高亮jquery插件SyntaxHighlighter使用教程
- 高功耗的USR-WIFI232-2b的sta+ap配置可以使手机连上互联网
- HDU 3830 - Checkers(二分LCA)****
- 中国剩余定理 poj1006
- lua元表
- 安装post man
- Cocos2d-js 3.2 技能冷却按钮的简单实现
- C语言中的异常处理机制
- c:foreach标签使用详解
- ios软件开发 json格式字符串转字典,字典转json格式字符串
- 《SICP》读书笔记--Chapter 1 Building Abstraction with Procedures
- 多线程系列一——何为线程与java中线程的创建