北大ACM(POJ1006-Biorhythms)
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)的更多相关文章
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- 北大 ACM 分类 汇总
1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...
- POJ1006 Biorhythms —— 中国剩余定理
题目链接:https://vjudge.net/problem/POJ-1006 Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total ...
- 北大ACM题库习题分类与简介(转载)
在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...
- POJ1006——Biorhythms(中国剩余定理)
Biorhythms Description人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色. ...
- 【学习笔记-中国剩余定理】POJ1006 Biorhythms
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 139500 Accepted: 44772 Des ...
- 北大ACM试题分类+部分解题报告链接
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- 北大ACM - POJ试题分类
1.入门水题 可用于练手与增强自信 POJ-1003POJ-1004 POJ-1005 POJ-1207 POJ-3299 POJ-2159 POJ-1083POJ-3094 2.初级 2.1. 基本 ...
- 北大ACM(POJ1014-Dividing)
Question:http://poj.org/problem?id=1014 问题点:抽屉原理.dfs.多重背包. Memory: 248K Time: 16MS Language: C++ Res ...
- 北大ACM(POJ1013-Counterfeit Dollar)
Question:http://poj.org/problem?id=1013 问题点:排除+验证. Memory: 244K Time: 16MS Language: C++ Result: Acc ...
随机推荐
- 前端优化分析 之 javascript引用位置优化
在很多优化法则中都提到,尽量将javascript放到页面底部,这是为什么呢 我通过firebug进行了下简单的分析 看下图 本页面首尾都存在javascript代码 我们分析得出 1.整个页面文档 ...
- Codeforces Round #312 (Div. 2)B. Amr and The Large Array 暴力
B. Amr and The Large Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- iOS开发——UI篇Swift篇&UIWebView
UIWebView //返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAn ...
- 百度UEditor组件出现Parameters: Invalid chunk '' ignored警告的分析
使用百度UEditor在线编辑器组件时,出现Parameters: Invalid chunk '' ignored的警告,之前的项目使用却没有.两个项目的环境应该是一样的. 没有时间去对照两项目使用 ...
- 疑难杂症:org.hibernate.MappingException: Unknown entity,annotation配置Entity类报错
引言: 夜声人静,外面下着稀里哗啦的雨,周末的晚上,还在键盘上舞动手指. 此刻很感激一个人一篇随笔,感谢xiaochao以及他的<org.hibernate.MappingException: ...
- 如何避免MVC Model First 设计时添加的DataAnnotation被覆盖掉
结合多方资料做一系统,发现Code First中所有代码要自己写,无法自动生成(暂时没有找到方法,有知道的大能,给指点一下,好像在NuGet中有一个插件可以直接从数据库中生成Code First所需类 ...
- centos6.4使用man查找命令时,报错No manual entry for xxxx
前提:安装man的命令 yum -y install man 使用man报错 [root@localhost objs]# man fcntlNo manual entry for fcntl[roo ...
- 3.3html学习笔记之链接
iframe 元素会创建包含另外一个文档的内联框架 <iframe src=""/> 跳转链接 <a href="#here" target= ...
- iOS 左右滑动 手势 响应方法
1. @property (nonatomic, strong) UISwipeGestureRecognizer *leftSwipeGestureRecognizer; @property (no ...
- Android Activity的启动过程
文章编辑的太长了,请移步我的csdn博客:http://blog.csdn.net/xyh269 Android Activity的启动过程原文链接:http://blog.csdn.net/xyh2 ...