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. Swift Explore - 关于 Swift 中的 isEqual 的一点探索

    在我们进行 App 开发的时候,经常会用到的一个操作就是判断两个对象是否相等.比如两个字符串是否相等.而所谓的 相等 有着两层含义.一个是值相等,还有一个是引用相等.如果熟悉 Objective-C ...

  2. MVC4.0 解决Controllers与Areas中控制器不能同名问题

    在使用MVC4.0的时候,难免会遇到在根目录下的Controllers中添加的控制器名称可能会跟在Areas中的某个区域下的控制器名称一样.这个时候访问Areas下面的Controller/Actio ...

  3. Some Tips About VS2015

    Xaml edit bug about vs2013+ sometimes, vs will say some class not found in the namespace. but, we co ...

  4. Entity Framework SqlFunctions 教你如何在EF调用sqlserver方法的函数存根

    今天算是研究了一天的SqlFunctions,请教了几个群的牛人,居然发现大伙对这个都比较陌生, 有的甚至直指EF中是不能调用sqlserver里的方法的. 因为之前搞过linq to sql 里面的 ...

  5. haproxy实现mysql从库负载均衡

    本文主要讲述通过haproxy实现mysql从库间的负载均衡,至于mysql主从的搭建,本文不再重述,可以参考我之前写的博客. 1.首先下载haproxy包 wget http://haproxy.1 ...

  6. “我爱淘”冲刺阶段Scrum站立会议9

    完成任务: 完成了webservice的配置与测试. 计划任务: 可以通过webservice将数据库中的内容解析出来,通过查询可以得到想要的内容. 遇到问题: 服务器已经配好,,也已经测试成功,不过 ...

  7. pxe+preseed安装配置(2)

    1.tftp使用独立daemon,这样不用再安装xinet, apt-get install tftp-hpa tftpd-hpa cat /etc/default/tftpd-hpa TFTP_US ...

  8. 【Flatten Binary Tree to Linked List】cpp

    题目: Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 ...

  9. 单点登陆CAS安装过程中可能遇到的问题

    可能遇到的问题: 错误: java.security.cert.CertificateException: No name matching localhost found 原因: keystore里 ...

  10. poj 3264 Balanced Lineup 区间极值RMQ

    题目链接:http://poj.org/problem?id=3264 For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) alw ...