生理周期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 ...
随机推荐
- 吴恩达机器学习笔记8-多变量线性回归(Linear Regression with Multiple Variables)--多维特征
我们探讨了单变量/特征的回归模型,现在我们对房价模型增加更多的特征,例如房间数楼层等,构成一个含有多个变量的模型,模型中的特征为(
- 使用idea配置tomcat将web项目跑起来
链接:https://www.cnblogs.com/avivaye/p/6437555.html
- __import__
__import__有个参数 fromlist =[]1.当这个参数为空的时候__import__('a.b.c') 等效于 import a 2.__import__('a.b.c', fromli ...
- JavaScript递归中的作用域问题
需求是这样的,从子节点寻找指定className的父节点,一开始就想到递归(笨!),Dom结构如下: <div class="layer_1"> <div cla ...
- vue项目 使用Hbuilder打包app 设置沉浸式状态栏
使用 Hbuilder新建好移动app项目后,mainfest.json这个文件里的 plus里设置 statusbar ..... "plus": { "statusb ...
- Centos6.5搭建grok匹配测试网站
最近在使用ELK对日志进行集中管理,因为涉及到日志的规则经常要用到http://grokdebug.herokuapp.com/进行调试,但是国外的网站访问太慢,这儿推荐一个国内的网站http://g ...
- Spring 依赖注入方式详解(四)
IoC 简介 平常的Java开发中,程序员在某个类中需要依赖其它类的方法. 通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理. Spring提出了依赖注入的思想 ...
- 征服诱人的Vagrant!
一.背景 最近要开始深入学习分布式相关的东西了,那第一步就是在自己的电脑上安装虚拟机,以前在Windows平台,我选择用VMware Workstation作为虚拟机软件,现在在Mac系统下,感觉 ...
- SLG手游Java服务器的设计与开发——架构分析
微信公众号[程序员江湖] 作者黄小斜,斜杠青年,某985硕士,阿里 Java 研发工程师,于 2018 年秋招拿到 BAT 头条.网易.滴滴等 8 个大厂 offer,目前致力于分享这几年的学习经验. ...
- ②泡茶看<数据结构>,喜欢看源码-栈ADT
前言 听着天籁,我是个音乐迷.时间充实着,会过得很快.我马上也可以到傍晚的时候去乐室吹我心爱的萨克斯. 嘟嘟嘟... 我会吹一首简单的歌咯,哈哈我想到了一个神奇的比喻,待会说. 栈ADT模型(又称LI ...