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天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色.例如,智力周期的高峰 ...
随机推荐
- 2.1 Oracle之DML的SQL语句之单表查询以及函数
1.SQL简介 对于不同的数据库来说,SQL语句是相通的,关系型数据库都以SQL语句为操作的标准,只是相应的数据库对应的函数不相同. SQL(Structured Query Language,结构化 ...
- SVN部署与简单使用
原文发表于cu:2016-05-24 参考文档: http://www.tuicool.com/articles/Yv2iyu7 http://www.centoscn.com/CentosServe ...
- 在intelij IDEA中添加对jetBrick文件的识别
在intelij IDEA中添加对jetBrick文件的识别 打开setting, 搜索File Types, 在Recognized File Types窗口找到Java Server Page或者 ...
- [转]oracle数据库定时任务dbms_job的用法详解
这篇文章给大家详细介绍了dbms_job的用法,用于安排和管理作业队列,通过使用作业,可以使ORACLE数据库定期执行特定的任务.有需要的朋友们可以参考借鉴. 一.dbms_job涉及到的知识点 ...
- 用js两张图片合并成一张图片
JS和canvas的合成方式 function drawAndShareImage(){ var canvas = document.createElement("canvas") ...
- kafka可靠性
文章转载自: http://blog.csdn.net/u013256816/article/details/71091774
- Python语言基础
一.Python简介 Python是跨平台动态语言 特点:优雅.明确.简单 适用:web网站和网络服务:系统工具和脚步:包装其他语言开发的模块 不适用:贴近硬件(首选C):移动开发:IOS/Andro ...
- Java微笔记(6)
- Nginx 配置站点
1-进入 配置文件夹 cd /etc/nginx/cof.d 2-创建一个一站点名称命名的配置文件 vim kestrel-syslyracom.conf 3-在.conf 文件中输入 ...
- 线段树-hdu2795 Billboard(贴海报)
hdu2795 Billboard 题意:h*w的木板,放进一些1*L的物品,求每次放空间能容纳且最上边的位子 思路:每次找到最大值的位子,然后减去L 线段树功能:query:区间求最大值的位子(直接 ...