Question:http://poj.org/problem?id=1006
问题点:孙子定理
 Memory: 248K        Time: 0MS
Language: C++ Result: Accepted
3
#include <iostream> using namespace std;
int getGCD(int a,int b)//Greatest Common Divisor
{
if(a<b){a+=b;b=a-b;a=a-b;}
if(b==) return ;
else if(a%b==) return a/b;
else return getGCD(b,a%b);
}
int getLCM(int a,int b)//Lowest Common Multiple
{
return a*b/getGCD(a,b);
}
int getMod1(int a,int b)//get N. a*N mod b ==1
{
int N=;
while(a*N%b!=){N++;}
return a*N;
}
int main()
{
int p,e,i,d,cnt=;
int pe=getMod1(getLCM(,),);
int pi=getMod1(getLCM(,),);
int ei=getMod1(getLCM(,),);
while(true)
{
cin>>p>>e>>i>>d;
if(p==-&&e==-&&i==-&&d==-) return ;
int m=(ei*p+pi*e+pe*i)%(**)-d;
if(m<=) m+=**;
cout<<"Case "<<cnt++<<": the next triple peak occurs in "<<m<<" days."<<endl;
}
}
 

北大ACM(POJ1006-Biorhythms)的更多相关文章

  1. 北大ACM - POJ试题分类(转自EXP)

    北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...

  2. 北大 ACM 分类 汇总

    1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...

  3. POJ1006 Biorhythms —— 中国剩余定理

    题目链接:https://vjudge.net/problem/POJ-1006 Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total ...

  4. 北大ACM题库习题分类与简介(转载)

    在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...

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

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

  6. 【学习笔记-中国剩余定理】POJ1006 Biorhythms

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 139500   Accepted: 44772 Des ...

  7. 北大ACM试题分类+部分解题报告链接

    转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...

  8. 北大ACM - POJ试题分类

    1.入门水题 可用于练手与增强自信 POJ-1003POJ-1004 POJ-1005 POJ-1207 POJ-3299 POJ-2159 POJ-1083POJ-3094 2.初级 2.1. 基本 ...

  9. 北大ACM(POJ1014-Dividing)

    Question:http://poj.org/problem?id=1014 问题点:抽屉原理.dfs.多重背包. Memory: 248K Time: 16MS Language: C++ Res ...

  10. 北大ACM(POJ1013-Counterfeit Dollar)

    Question:http://poj.org/problem?id=1013 问题点:排除+验证. Memory: 244K Time: 16MS Language: C++ Result: Acc ...

随机推荐

  1. http://www.jobui.com/mianshiti/it/java/6782/

    1.运算符优先级问题,下面代码的结果是多少?(笔试) package test; public class Test {public static void main(String[] args) { ...

  2. wp8 在OnBackKeyPress事件中调用MessageBox.Show()崩溃

    今天写代码的时候遇到一个问题,在wp8中执行下面的代码后,弹出对话框后,停滞一段时间程序退出. protected override void OnBackKeyPress(CancelEventAr ...

  3. Android Studio系列教程一--下载与安装

    背景 相信大家对Android Studio已经不陌生了,Android Studio是Google于2013 I/O大会针对Android开发推出的新的开发工具,目前很多开源项目都已经在采用,Goo ...

  4. Android Activity界面切换添加动画特效(转)

    在Android 2.0之后有了overridePendingTransition() ,其中里面两个参数,一个是前一个activity的退出两一个activity的进入, @Override pub ...

  5. ASCII码对应表

    chr(9) tab空格       chr(10) 换行      chr(13) 回车        Chr(13)&chr(10) 回车换行       chr(32) 空格符      ...

  6. windows下如何github ssh 公钥

    windows下如何github ssh 公钥   1. 安装git,从程序目录打开 "Git Bash"  2. 键入命令:ssh-keygen -t rsa -C " ...

  7. percona-xtrabackup 文档

    https://www.percona.com/doc/percona-xtrabackup/2.4/index.html

  8. 解决ajax.net 1.0中文乱码问题!

      在使用ajax.net的UpdatePanel的时候,当requestEncoding编码为GB2312的时候,出现乱码.如果要解决这个问题最简单的就是改用utf-8了,但是原来使用GB2312, ...

  9. LeetCode38 Count and Say

    The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...

  10. tachyon 配置项

    Tachyon 配置参数分为4类:Master,Worker, Common (Master and Worker), and User configurations. 环境变量配置文件在$TACHY ...