生理周期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 虚拟机的内存溢出
在Java虚拟机规范的描述中,除了程序计数器外,虚拟机内存的其他几个运行时区域都有发生 OutOfMemoryError 异常的可能. 在Eclipse中进行JVM参数设置 可以直接通过上方菜单栏的 ...
- 工作随笔—static关键字
问题:在声明一个变量的时候,添加static与不添加static区别在哪里? 回答:在声明一个变量的时候,添加static关键字,那么这个变量就会在保存在代码器里面,而不会保存到堆里面去了,当其余的对 ...
- C# 配置文件Xml读写
分析xxx.exe.config文件: <?xml version="1.0" encoding="utf-8"?> <configurati ...
- TCPWrap的使用配置
参考地址: http://www.softpanorama.org/Net/Network_security/TCP_wrappers/index.shtml http://generationip. ...
- 插槽slot
主要是让组件的可扩展性更强.1.匿名slot使用 //定义组件my-component <div class="myComponent"> <slot>&l ...
- perl选项、特殊变量、一些函数参考手册
perl一行式程序系列文章:Perl一行式 本文用来收集Perl一行式中涉及到的一些选项.特殊变量的说明,可以用来做速查手册. 本文会逐渐更新. 第一次学Perl一行式时,请直接忽略本文内容,并直接从 ...
- go基础系列:简介
1.Go简介 Go语言是编译型.静态类型的类C的语言,并带有GC(垃圾收集器,garbage collection).这意味着什么? 另外,Go是一种非常严格的语言,它几乎总是要求我们"以标 ...
- C# 获取一定区间的随即数 0、1两个值除随机数以外的取值方法(0、1两个值被取值的概率相等)
获取随机数 举例:0-9 Random random = new Random(); int j = random.Next(0, 9); 0.1两个值被取值的概率相等 int a = Math.Ab ...
- [转]nodejs中package.json和package-lock.json文件的功能分析
本文转自:https://blog.csdn.net/u013992330/article/details/81110018 最新版nodejs中,多了一个package-lock.json文件,刚开 ...
- C#正则表达式。
什么是正则表达式: 正则表达式是用来进行文本处理的技术,是语言无关的. 是由普通字符和特殊字符组成的文字模式,用来描述字符串的特征. 元字符: 1. . : 除 \n 以外的任意的单个字符. ...