生理周期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 ...
随机推荐
- ubuntu16.04 在线安装docker ce
官方文档:https://docs.docker.com/install/linux/docker-ce/ubuntu/ ubuntu创建普通用户: adduser dk001 给该用户添加sud ...
- Android--UI之GridView
前言 这篇博客介绍一下Android平台下,GridView控件的开发.针对GridView控件的一些常用属性.方法,以及注意事项进行讲解,最后将以一个Demo展示GridView控件的使用. Gri ...
- 通用Web后台魔方NewLife.Cube
魔方 是一个基于 ASP.NET MVC 的 用户权限管理平台,可作为各种信息管理系统的基础框架. 演示:http://cube.newlifex.com 源码 源码: http://git.newl ...
- jvm的那些设置参数你都知道吗
前言 大家都知道,jvm在启动的时候,会执行默认的一些参数.一般情况下,这些设置的默认参数应对一些平常的项目也够用了.但是如果项目特别大了,需要增加一下堆内存的大小.或者是系统老是莫明的挂掉,想查看下 ...
- mysql年初至今聚合
年初至今聚合和滑动聚合类似,不同的地方仅在于统计的仅为当前一年的聚合.唯一的区别体现在下限的开始位置上.在年初至今的问题中,下限为该年的第一天,而滑动聚合的下限为N个月的第一天.因此,年初至今的问题的 ...
- [转]Redis配置文件详解
本文转自http://blog.csdn.net/neubuffer/article/details/17003909 redis是一款开源的.高性能的键-值存储(key-value store),和 ...
- Tomcat:At least one JAR was scanned for TLDs yet contained no TLDs
启动Tomcat的时候,经常见到这样的BUG: 14-Apr-2019 13:53:25.198 信息 [localhost-startStop-1] org.apache.jasper.serv ...
- 安装haproxy和haproxy命令
HaProxy系列文章:http://www.cnblogs.com/f-ck-need-u/p/7576137.html 1.安装haproxy CentOS自带了haproxy,但可能版本比较老. ...
- QT 设置有效绘图区域
void QPainter::setClipRect(int x, int y, int width, int height, Qt::ClipOperation operation = Qt::Re ...
- 我的python渗透测试工具之主机嗅探
嗅探工具的主要目标是基于UDP发现目标网络中的存活主机,选择UDP的原因是UDP访问过程开销小. 由于很多的操作系统在处理UDP端口的闭合时都会存在一个共性,我们也正是利用这个共性来开展确定此IP上是 ...