hdu1370-Biorhythms】的更多相关文章

0.引子 每一个讲中国剩余定理的人,都会从孙子的一道例题讲起 有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二.问物几何? 1.中国剩余定理 引子里的例题实际上是求一个最小的x满足 关键是,其中r1,r2,--,rk互质 这种问题都有多解,每一个解都为最小的解加上若干个lcm(r1,r2,...,rk),这个不用我证了吧(-_-||) 解决这个问题的方法是构造法, 先构造k个数 满足, 这样就保证 ,但是由于 bi 乘了除 ri 以外所有 r,所以bi模其它的 r 都为 0, 再把所有 b…
Biorhythms 题意:读入p,e,i,d 4个整数,已知(n+d)%23=p;   (n+d)%28=e;   (n+d)%33=i ,求n .        (题在文末) 知识点:中国剩余定理. /*解释*/ 题解:已知(n+d)%23=p;   (n+d)%28=e;   (n+d)%33=i        33×28×a模23的逆元为8,  则33×28×8=5544:        23×33×b模28的逆元为19,则23×33×19=14421:        23×28×c模3…
中国剩余定理 问题引入: 有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二.问物几何?<孙子算经> 就是计算一个数\(x\)满足\(\begin{cases} x≡2(MOD\ 3) \\ x≡3(MOD\ 5) \\ x≡2(MOD\ 7) \end{cases}\) 中国剩余定理: 首先对于同余方程,以下等式显然成立: \[(\sum a_i)\%p ≡ \sum (a_i\%p)\ (MOD\ p)① \] 接下来我们构造三个数\(a,b,c\)满足以下条件: \[\left[ \…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 110991   Accepted: 34541 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 physical,…
B - Biorhythms Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1006 Description 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维敏捷,精力容易高度集中.因为三个周期的周长…
一. 题目 Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 127263   Accepted: 40329 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…
1.链接地址: http://poj.org/problem?id=1006 http://bailian.openjudge.cn/practice/2977 2.题目: Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 107909   Accepted: 33478 Description Some people believe that there are three cycles in a p…
Biorhythms Time Limit: 1000MS Memory Limit: 10000KB  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 physical, emotional, and intellectual cycles,…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 127339   Accepted: 40342 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 physical,…
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 physical, emotional, and intellectual cycles, and they have periods of lengths 23, 28, and 33 days, respec…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 117973   Accepted: 37026 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 physical,…
孙子定理: 当前存在三个式子,t%3=2,t%5=3,t%7=2.然后让你求出t的值的一个通解. 具体过程:选取3和5的一个公倍数t1能够使得这个公倍数t1%7==1,然后选取3和7的一个公倍数t2使得这个公倍数t2%5==1,然后再选取5和7的一个公倍数t3使得这个公倍数t3%3==1,求出来 t1==15,t2==21,t3==70,然后最终的答案就是(15*3+21*3+70*2)+105*n.这里的105指的是3 5 7 的最小公倍数,为什么这样做?既然是有余数,那么就把这个余数搞没了就…
http://shuxueshi.jie.blog.163.com/blog/static/13611628820104179856631/ 这篇博客写的很棒! #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int a,b,c,t; int i,j; ; while(scanf("%d%d%d%d",&a,&b,&c,&t)!=…
UVA756 Biorhythms crt crt裸题 因为模数已知所以有些值能直接求 #include<iostream> #include<cstdio> using namespace std; typedef long long ll; ll p,e,i,d,lcm=,ans,t; int main(){ ){ cin>>p>>e>>i>>d; ) break; ans=(*p+*e+*i-d+lcm)%lcm; //exgc…
Biorhythms Description人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维敏捷,精力容易高度集中.因为三个周期的周长不同,所以通常三个周期的高峰不会落在同一天.对于每个人,我们想知道何时三个高峰落在同一天.对于每个周期,我们会给出从当前年份的第一天开始,到出现高峰的天数(不一定是第一次高峰出现的时间).你的任务是给定一个从当年第一天开始数的天…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103539   Accepted: 32012 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 physical,…
E - Biorhythms Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status 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…
POJ.1006 Biorhythms (拓展欧几里得+中国剩余定理) 题意分析 不妨设日期为x,根据题意可以列出日期上的方程: 化简可得: 根据中国剩余定理求解即可. 代码总览 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; typedef int ll; ll p,e,i,d; void exgcd(ll a,…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 139500   Accepted: 44772 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 physical,…
    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 107569   Accepted: 33365 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 physi…
题目链接:https://vjudge.net/problem/POJ-1006 Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 141576   Accepted: 45491 Description Some people believe that there are three cycles in a person's life that start the day he or she is b…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 111285   Accepted: 34638 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 physical,…
A - Biorhythms 链接:https://vjudge.net/contest/154063#problem Description 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维敏捷,精力容易高度集中.因为三个周期的周长不同,所以通常三个周期的高峰不会落在同一天.对于每个人,我们想知道何时三个高峰落在同一天.对于每个周期,我们会给出从当前年份的第…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 138926   Accepted: 44590 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 physical,…
Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 121194   Accepted: 38157 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 physical,…
http://poj.org/problem?id=1006 (题目链接) 题意 人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天.一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好.通常这三个周期的峰值不会是同一天.现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期.然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出现. Solution http://www.cnblogs.com/MashiroSky/p/59…
在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://acm.hdu.edu.cn/showproblem.php?pid=1370 /************************************************************************* > File Name: xh.cpp > Author: XINHUA > Mail: 525799145@qq.com > Created Time: 2013/7/11 星期四 17:46:00 新华 *****…
题目大意 略...有中文... 题解 就是解同余方程组 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…
题目地址:POJ 1006 学习了下中国剩余定理.參考的该博客.博客戳这里. 中国剩余定理的求解方法: 假如说x%c1=m1,x%c2=m2,x%c3=m3.那么能够设三个数R1,R2,R3.R1为c2,c3的公倍数且余c1为1,同理.R2,R3也是如此.然后设z=R1*m1+R2*m2+R3*m3,那么z就是当中一个解.并且每隔(c1,c2,c3)的最小公倍数就是一个解.想要最小解的话,仅仅需对最小公倍数取余即可了. 以下的代码未删改.比赛的时候为了避免超时,R1,R2,R3的求解过程全然没有…