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天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰 ...
随机推荐
- socket_tcp协议_loadrunner测试
1.lrs_create_socket("socket0", "TCP", "RemoteHost=127.0.0.1:8888", Lrs ...
- 如何选择 .NET Framework目标版本
如何选择 .NET Framework目标版本 简介 .NET Framework是所有 .NET程序赖以运行的基础. 版本 到目前位置 .NET Framework共出了: .NET Framewo ...
- Spark配置参数的三种方式
1.Spark 属性Spark应用程序的运行是通过外部参数来控制的,参数的设置正确与否,好与坏会直接影响应用程序的性能,也就影响我们整个集群的性能.参数控制有以下方式:(1)直接设置在SparkCon ...
- ElasticSearch之CURL操作(有空再去整理)
https://www.cnblogs.com/jing1617/p/8060421.html ElasticSearch之CURL操作 CURL的操作 curl是利用URL语法在命令行方式下工 ...
- Thunder——互评beta版本
基于NABCD和spec评论作品 Hello World!:http://www.cnblogs.com/vector121/p/7922989.html 欢迎来怼:http://www.cnblog ...
- JDK,JRE,JVM之间的关系
JDK包括JRE包括JVM http://java-mzd.iteye.com/blog/838514
- Spring 依赖的Jar包简介
Spring 依赖的Jar包简介 Spring的依赖关系 依赖关系分组 JAR文件 说 明 ant ant.jar, ant-junit.jar, ant-launcher.jar Spring采用A ...
- alpha发布评论
飞天小女警我们自己的礼物挑选工具完整度不高,页面简陋,还有很多需要完善和改进的地方,空间比较大,但是本身能力太不足. 个人比较喜欢奋斗吧兄弟做的食物链系统.感觉是可以拿来用的工具吧. 天天向上的游戏连 ...
- Ubuntu 下升级 php
起因: 在现有的 Apache + PHP 环境下,增加一个 PHP Extension 扩展时,遇到错误: Unable to initialize moduleModule compiled wi ...
- 【C++】C++的构造函数
构造函数是特殊的成员函数,只要创建类类型的对象,都要执行构造函数.构造函数的工作是保证每个对象的数据成员具有合适的初始值. class Sales_Item { public: //operation ...