一,题意:右上角中文。
二,思路:
  1,由题意得出方程组
  2,利用中国剩余定理求解
  3,求出最小正整数
三,步骤:
  1,由题意得出方程组

      (n+d) % 23 = p ;
      (n+d) % 28 = e ;
      (n+d) % 33 = i ;
2,中国剩余定理求解
  i,从23和28的公倍数中找出x,且满足x%33 = 1 ,x=1288
  ii,从23和33的公倍数中找出y,且满足y%28 = 1 ,y=14421
  iii,从28和33的公倍数中找出z,且满足z%23 = 1 ,z=5544
  iiii,s = (n+d) = (5544*p+14421*e+1288*i) % lcm(23,28,33); lcm为最小公倍数 =21252;
3, 求最小正整数解
  i,防止n为负数:n=(n+21252)%21252
  注意当n=0时,结果输出21252。

 #include<iostream>
using namespace std; int main(){
int p,e,i,d,n,s,l=;
while(cin>>p>>e>>i>>d){
if(p==-&&e==-&&i==-&&d==-)break;
int n=(*p+*e+*i)%-d;
n= (n+)%; //防止 s 是负数
if(n==)
n=;
printf("Case %d: the next triple peak occurs in %d days.\n",l++,n);
}
return ;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

poj1006-Biorhythms(中国剩余定理)的更多相关文章

  1. POJ1006——Biorhythms(中国剩余定理)

    Biorhythms Description人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色. ...

  2. Biorhythms(中国剩余定理)

    http://shuxueshi.jie.blog.163.com/blog/static/13611628820104179856631/ 这篇博客写的很棒! #include<stdio.h ...

  3. POJ 1006 - Biorhythms (中国剩余定理)

    B - Biorhythms Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Subm ...

  4. POJ 1006 Biorhythms --中国剩余定理(互质的)

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103539   Accepted: 32012 Des ...

  5. POJ 1006 Biorhythms(中国剩余定理)

    题目地址:POJ 1006 学习了下中国剩余定理.參考的该博客.博客戳这里. 中国剩余定理的求解方法: 假如说x%c1=m1,x%c2=m2,x%c3=m3.那么能够设三个数R1,R2,R3.R1为c ...

  6. PKU POJ 1006 Biorhythms (中国剩余定理)

    中国剩余定理 x = ai (mod mi)  ai和mi是一组数,mi两两互质,求x 令Mi = m1*m2*~mk     其中,mi不包含在内. 因为mi两两互质,所以存在x和y, st   M ...

  7. poj1006 / hdu1370 Biorhythms (中国剩余定理)

    Biorhythms 题意:读入p,e,i,d 4个整数,已知(n+d)%23=p;   (n+d)%28=e;   (n+d)%33=i ,求n .        (题在文末) 知识点:中国剩余定理 ...

  8. poj1006 中国剩余定理&&中国剩余定理解析

    poj 1006 题的思路不是很难的,可以转化数学式: 现设 num 是下一个相同日子距离开始的天数 p,e,i,d 如题中所设! 那么就可以得到三个式子:( num + d ) % 23 == p: ...

  9. 【中国剩余定理】 poj 1006

    生理周期  简单模拟 对于超出23 * 28 * 33(21252)时进行求余运算即可. #include<stdio.h> int main() { //freopen("in ...

  10. Biorhythms(poj1006+中国剩余定理)

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 117973   Accepted: 37026 Des ...

随机推荐

  1. Xamarin.iOS编译出错

    Xamarin.iOS编译出错 错误信息:C:/Program Files(x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0 ...

  2. vs2010 安装MVC 3.0

    下载链接如下: MVC 3安装包:http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=d2928bc1-f48c-4e95-a ...

  3. Linux profile File

    umask 022alias vim="/pd/vim/7.1/bin/vim"if [ -e /usr/bin/vim ]; then alias vim="/usr/ ...

  4. Android自动化测试 - MonkeyRunner(二) 锤子便签测试脚本

    来源于:http://testerhome.com/topics/878 # encoding=utf-8 #导入python中自带的time模块和sys模块,脚本中都要用到它们. import ti ...

  5. 转载:robotium typeText与enterText区别

    solo.typeText和solo.enterText方法都可以对EditeText进行测试,达到的测试目的是一样的.存在几点不同: 1.实现上,typeText方法是robotium框架调用系统I ...

  6. LA4671 K-neighbor substrings(FFT + 字符串Hash)

    题目 Source http://acm.hust.edu.cn/vjudge/problem/19225 Description The Hamming distance between two s ...

  7. EF框架step by step(4)—DBcontext应用于已存在数据库

    EF4.1有三种方式来进行数据操作及持久化.分别是Database-First,Model-First,Code-first,前面都已经简单介绍过了.下面简单小结一下:1.Database First ...

  8. CF#335 Sorting Railway Cars

    Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  9. Unity 逐步旋转

    npc.transform.rotation = Quaternion.Slerp(npc.transform.rotation, Quaternion.LookRotation(moveDir), ...

  10. Hibernate4Maven

    How to create a Maven project with Hibernate libs? This blog will be a demo to describe this issue. ...