Biorhythms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the phy…
POJ 1006 生理周期 分析:中国剩余定理(注意结果要大于d即可) 代码: #include<iostream> #include<cstdio> using namespace std; int n1, n2, n3, n; void solve() { n1 = *; != ) n1 += *; n2 = *; != ) n2 += *; n3 = *; != ) n3 += *; n = **; } int main() { ; solve(); ) { int p, e…
http://poj.org/problem?id=1006 题目大意: 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维敏捷,精力容易高度集中.因为三个周期的周长不同,所以通常三个周期的高峰不会落在同一天.对于每个人,我们想知道何时三个高峰落在同一天.对于每个周期,我们会给出从当前年份的第一天开始,到出现高峰的天数(不一定是第一次高峰出现的时间).你的任务是…
在POJ上有译文(原文右上角),选择语言:简体中文 求解同余方程组:x=ai(mod mi) i=1~r, m1,m2,...,mr互质利用中国剩余定理令M=m1*m2*...*mr,Mi=M/mi因为mi两两互质,所以(Mi,mi)=1令Mi*yi=1(mod mi)的解为yi,即Mi模mi的逆元则方程的解为:(a1*M1*y1+a2*M2*y2+...+ar*Mr*yr)%M 方法一:用扩展欧几里德求逆元 #include <iostream> #include <stdio.h&g…
http://poj.org/problem?id=1006 题意: (n+d) % 23 = p ;(n+d) % 28 = e ;(n+d) % 33 = i ; 求最小的n. 思路: 这道题就是中国剩余定理. #include<iostream> #include<algorithm> #include<string> #include<cstring> #include<cmath> using namespace std; int n;…
扩展中国剩余定理的板子,合并完之后算一下范围内能取几个值即可(记得去掉0) #include<iostream> #include<cstdio> #include<cmath> using namespace std; const int N=15; int T,n,m; long long a[N],b[N],A,B,x,y,d; bool fl; void exgcd(long long a,long long b,long long &d,long lo…
超级无敌简单题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 570    Accepted Submission(s): 274 Problem Description 通常来说,题面短的题目一般都比较难,所以我要把题面写得很长很长.通常来说,题面短的题目一般都比较难,所以我要把题面写得很长很长.通常来说,题面短的题目一般都比较难,所…
Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera with a few ships, starting a serious of voyages of finding a new route to India. As you know, just in those voyages, Columbus discovered the America…
http://poj.org/problem?id=2891 题意:求解一个数x使得 x%8 = 7,x%11 = 9; 若x存在,输出最小整数解.否则输出-1: ps: 思路:这不是简单的中国剩余定理问题,由于输入的ai不一定两两互质,而中国剩余定理的条件是除数两两互质. 这是一般的模线性方程组,对于 X mod m1=r1 X mod m2=r2 ... ... ... X mod mn=rn 首先,我们看两个式子的情况 X mod m1=r1-----------------------(…
题目大意 略...有中文... 题解 就是解同余方程组 x≡(p-d)(mod 23) x≡(e-d)(mod 28) x≡(i-d)(mod 33) 最简单的中国剩余定理应用.... 代码: #include<iostream> #include<cstdio> using namespace std; void gcd(int a,int b,int &d,int &x,int &y) { if(!b) { d=a,x=,y=; } else { gcd…