http://poj.org/problem?id=1006

题意:中国剩余定理的裸题。

题目可转化为求最小的x满足以下条件:

x%23=a;
x%28=b;
x%33=c;

关于中国剩余定理可看我昨天的博文:http://www.cnblogs.com/KonjakJuruo/p/5176417.html

//poj1006
/*
x%23=a;
x%28=b;
x%33=c;
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std; int tx,ty;
/*
void exgcd(int a,int b)
{
if(b==0) {tx=1,ty=0;return ;}
exgcd(b,a%b);
int x=ty,y=tx-(a/b)*ty;
tx=x;ty=y;
}
*/
int main()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
int T=;
while()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a==- && b==- && c==- && d==-) return ;
int x=*a**;
int y=-*b**;
int z=*c**;
int g=**;
int ans=(x+y+z)%g;
while(ans-d <= ) ans+=g;
while(ans-d > g) ans-=g;
printf("Case %d: the next triple peak occurs in %d days.\n",++T,ans-d);
}
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. iOS学习之C语言循环结构

    一.while循环    while (循环条件) {        循环体:    }    // 1.定义循环变量    int time = 1;    // 2.循环条件    while ( ...

  2. Entity Framework 学习第二天 续

    今天来写一点不一样的删除,修改,查询 下面只写了几个方法 /// <summary> /// 根据删除条件进行删除 /// </summary> /// <param n ...

  3. 无法加载一个或多个请求的类型。有关更多信息,请检索 LoaderExceptions 属性

    一解决方法: 问题的主要原因出在:跨程序集反射. 即我们需反射的A.dll的程序集引用B.dll程序集,而在反射工具项目中却不存在对B.dll程序集的引用.因此我们只需在反射工具项目中添加对B.dll ...

  4. 55.ERROR:Place:1136 - This design contains a global buffer instance…… non-clock load pins off chip

    ISE在布局布线时,出现下图所示错误. 对于"clock_dedicated_route”错误原因有两种情况: 1.  就是有一个时钟你没有放到全局时钟或者局部时钟的引脚,布局的时候不能把它 ...

  5. 带搜索框的下拉框chosen.jQury.js

    下载所需js,css png资源     <link href="chosen.css" rel="stylesheet" type="text ...

  6. The income statement

    The income statement measures performance over some period  of time,usually a quarter or a year.The ...

  7. 《Soft Skill》一书中的好句子

    The biggest mistake that you can make is to believe that you are working for somebody else. Job secu ...

  8. 【环境】VS2013和MATLAB相互调用混合编程

    Visual Studio和MATLAB混合编程,有两种方法: 1 MATLAB调用C程序: 2 VS调用MATLAB(目前见到的都是VS,其他编译器如codeblocks,或不提供这项功能): 前一 ...

  9. 项目开发-->一键登录功能汇总

    开发网站经常会提供一些一键登录功能,如:QQ.新浪微博.淘宝账号.开心网账号.人人网账号等进行快捷登录,下面记录几个常用的开放平台地址,方便以后开发需要. 1.QQ互联 2.新浪微博 网站接入QQ互联 ...

  10. 【转】EXT VTYPE自定义举例

    原文地址:http://www.blogjava.net/xiaohuzi2008/archive/2012/12/08/392676.html 近日来对Ext特别感兴趣,也许是它那种OO的设计思想吸 ...