生理周期POJ 1006
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 138101 | Accepted: 44225 |
Description
Input
当p = e = i = d = -1时,输入数据结束。
Output
采用以下格式:
Case 1: the next triple peak occurs in 1234 days.
注意:即使结果是1天,也使用复数形式“days”。
Sample Input
0 0 0 0
0 0 0 100
5 20 34 325
4 5 6 7
283 102 23 320
203 301 203 40
-1 -1 -1 -1
Sample Output
Case 1: the next triple peak occurs in 21252 days.
Case 2: the next triple peak occurs in 21152 days.
Case 3: the next triple peak occurs in 19575 days.
Case 4: the next triple peak occurs in 16994 days.
Case 5: the next triple peak occurs in 8910 days.
Case 6: the next triple peak occurs in 10789 days.
Source
Translator
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const int MAXN=;
inline void read(int &n)
{
char c='+';int x=;bool flag=;
while(c<''||c>''){c=getchar();if(c=='-')flag=;}
while(c>=''&&c<=''){x=x*+(c-);c=getchar();}
flag==?n=-x:n=x;
}
int getgcd(int a,int b)
{
return b==?a:getgcd(b,a%b);
}
int exgcd(int a,int b,int &x,int &y)
{
if(b==)
{
x=;
y=;
return a;
}
int r=exgcd(b,a%b,x,y);
int tmp=x;
x=y;
y=(tmp-(a/b)*y);
return r;
}
int crt(int *a,int *m,int num)
{
int M=,ans=;
for(int i=;i<=num;i++)
M*=m[i];
int x,y;
for(int i=;i<=num;i++)
{
int nowm=(M/m[i]);
int remain=exgcd(nowm,m[i],x,y);
ans=(ans+a[i]*nowm*x)%M;
}
return ans;
}
int tl,qg,zs,day;
int now=;
int a[MAXN];
int m[MAXN];
int main()
{
ios::sync_with_stdio();
m[]=;
m[]=;
m[]=;
int tot=;
while(cin>>a[]>>a[]>>a[]>>day)
{
if(a[]==-)break;
int out=crt(a,m,);
if(out<=day)
out+=;
printf("Case %d: the next triple peak occurs in %d days.\n",++tot,out-day);
}
return ;
}
生理周期POJ 1006的更多相关文章
- POJ 1006 生理周期(中国剩余定理)
POJ 1006 生理周期 分析:中国剩余定理(注意结果要大于d即可) 代码: #include<iostream> #include<cstdio> using namesp ...
- [POJ 1006]生理周期
Description 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰 ...
- POJ 1006 生理周期【数论】
这题是有中文版的(右上角选项卡里把default改成简体中文)然后看到他把biorhythms翻成生理周期我可耻的笑了......23333 如果没有限定从日期d开始,完全可以从第一天起开始计时,因此 ...
- poj——1006 生理周期
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 138291 Accepted: 44300 Descripti ...
- POJ 1006 - Biorhythms (中国剩余定理)
B - Biorhythms Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Subm ...
- poj 1006 Biorhythms (中国剩余定理模板)
http://poj.org/problem?id=1006 题目大意: 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这 ...
- [POJ 1006] Biorhythms C++解题
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 107569 Accepted: 33365 ...
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110991 Accepted: 34541 Des ...
- 生理周期[PKU1006]
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 132195 Accepted: 42171 Descripti ...
随机推荐
- 使用Java面向对象单词必备
第一章 class 班级,用声明类 object 目标,整个程序集对大 static 静态的 final 不可更改的,用声明常量 private 私有的,用访问权限 public ...
- [Postman]授权(11)
授权过程将验证您是否有权从服务器访问所需的数据.发送请求时,通常必须包含参数以确保请求具有访问权限并返回所需数据.Postman提供的授权类型使您可以轻松处理Postman本机应用程序中的身份验证协议 ...
- python 按照一个字典的值来对这个字典进行排序
old_dic = {'a':6, 'b':3, 'c':2, 'd':4, 'e':5, 'f':1}new_dic = sorted(old_dic.items(), key=lambda d:d ...
- 数据库占用cpu较高的查询
近来看到别人的有关数据库查询cpu占用较高的sql语句(本人sql并不好),所以查询了一下资料,记录一下,便于理解和应用. 首先,将语句贴在这里 SELECT TOP 10 --平均cpu时间 tot ...
- Java 基础:hashCode方法
Writer:BYSocket(泥沙砖瓦浆木匠) 微博:BYSocket 豆瓣:BYSocket 一.前言 泥瓦匠最近被项目搞的天昏地暗.发现有些要给自己一些目标,关于技术的目标: 专注很重要.专注J ...
- Go随机数
Go math/rand包用于生成随机数. 代码: package main import "fmt" import "math/rand" func main ...
- PHP接口的思考
其中就有一个SPL(标准PHP库)的尝试,SPL中实现一些接口,其中最主要的就是Iterator迭代器接口,通过实现这个接口,就能使对象能够用于foreach结构,从而在使用形式上比较统一.比如SPL ...
- SHELL脚本--多命令逻辑执行顺序
bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html Linux中可以使用分号“;”.双and号“&& ...
- shell脚本示例:批量比较多个文件的内容是否相同
bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 要比较两个文件的内容是否完全一致,可以简单地使用diff命令. ...
- iOS面试准备之思维导图
以思维导图的方式对iOS常见的面试题知识点进行梳理复习,文章xmind点这下载,文章图片太大查看不了也点这下载 你可以在公众号 五分钟学算法 获取数据结构与算法相关的内容,准备算法面试 公众号回复 g ...