poj1006 生理周期
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 138947 | Accepted: 44597 |
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 <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath> using namespace std; const int mod = ; int d,a[];
int cnt = ,ans,M;
int m[] = {,,,}; void exgcd(int a,int b,int &x,int &y)
{
if (!b)
{
x = ;
y = ;
return;
}
exgcd(b,a % b,x,y);
int t = x;
x = y;
y = t - (a / b) * y;
return;
} void china()
{
ans = ,M = ;
for (int i = ; i <= ; i++)
M *= m[i];
for (int i = ; i <= ; i++)
{
int mi = M / m[i];
int x,y;
exgcd(mi,m[i],x,y);
ans = (ans + a[i] * mi * x) % M;
}
if (ans < )
ans += M;
} int main()
{
while (scanf("%d%d%d%d",&a[],&a[],&a[],&d) && a[] >= && a[] >= && a[] >= && d >= )
{
cnt++;
china();
if (ans <= d)
ans += mod;
ans -= d;
printf("Case %d: the next triple peak occurs in %d days.\n",cnt,ans);
} return ;
}
poj1006 生理周期的更多相关文章
- 【同余方程组】POJ1006 生理周期
同余方程组: 先来看一道题目:有物不知其数,三三数之剩二:五五数之剩三:七七数之剩二.问物几何? 然后我们可以做如下变换,设x为所求的数. x%3=2 x ≡ a1(%m1 ...
- poj1006生理周期(中国剩余定理)
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 139224 Accepted: 44687 Descripti ...
- 【数论】【中国剩余定理】poj1006 生理周期
CRT用于求解一元线性同余方程组(模数互质),实际上模数不互质我们也可以解决,在之前的某篇文章里提过.如下 http://www.cnblogs.com/autsky-jadek/p/6596010. ...
- poj1006生理周期(中国剩余定理)
/* 中国剩余定理可以描述为: 若某数x分别被d1..….dn除得的余数为r1.r2.….rn,则可表示为下式: x=R1r1+R2r2+…+Rnrn+RD 其中R1是d2.d3.….dn的公倍数,而 ...
- [POJ1006]生理周期 (中国剩余定理)
蒟蒻并不会中国剩余定理 交的时候还出现了PE的错误 下面是AC代码 #include<iostream> #include<cstdio> using namespace st ...
- 生理周期[PKU1006]
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 132195 Accepted: 42171 Descripti ...
- 生理周期(c++实现)
描述:人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23 天. 28 天和33 天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维 ...
- ACM第二题 生理周期
人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰,人会思维敏捷,精力容易 ...
- [POJ 1006]生理周期
Description 人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰 ...
随机推荐
- R之RMySQL
linux,mysql和R的版本信息: Linux naci 3.19.0-16-generic #16-Ubuntu SMP Server version: 5.6.24-0ubuntu2 (Ubu ...
- 【Python进阶】无论API怎么变,SDK都可以根据URL实现完全动态的调用
现在很多网站都搞REST API,比如新浪微博.豆瓣啥的,调用API的URL类似: http://api.server/user/friends http://api.server/user/time ...
- MySQL Proxy和 Amoeba 工作机制浅析
MySQL Proxy处于客户端应用程序和MySQL服务器之间,通过截断.改变并转发客户端和后端数据库之间的通信来实现其功能,这和WinGate 之类的网络代理服务器的基本思想是一样的.代理服务器是和 ...
- ASP.NET MVC - 启动创建项目,未能加载错误
VS2012以常规方式创建一ASP.NET MVC internet 项目.创建后F5启动项目,遇一错误: 未能加载文件或程序集“MySql.Web.v20, Version=6.9.4.0, Cul ...
- 如何把node更新到最新的稳定版本
先装n,再用n把node升级到最新稳定版 $ npm install -g n $ n stable
- 第16次Scrum会议(10/28)【欢迎来怼】
一.小组信息 队名:欢迎来怼小组成员队长:田继平成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华小组照片 二.开会信息 时间:2017/10/28 17:20~17:32,总计12min.地点:东北师范 ...
- 2016-2017 ACM-ICPC Northeastern European Regional Contest Problem E. Expect to Wait
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229509 时间限制:2s 空间限制:512MB 题目大意: 在一个车站中有若干人在队列中等待 ...
- Web.config配置configSections学习
文章:c# 配置文件之configSections配置 configSections节点需要位于configuration第一的位置,紧挨configuration. <configuratio ...
- Hibernate:工作原理
Hibernate的工作原理图如下所示:
- Scrum Meeting Beta - 2
Scrum Meeting Beta - 2 NewTeam // 地点:新主楼F座二楼 任务反馈 团队成员 完成任务 计划任务 安万贺 了解缓存的相关内容Issue #109 设计本地存储的方案Is ...