POJ1006-Biorhythms
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 129706 | Accepted: 41287 |
Description
peak in each period of a cycle. At the peak of a cycle, a person performs at his or her best in the corresponding field (physical, emotional or mental). For example, if it is the mental curve, thought processes will be sharper and concentration will be easier.
Since the three cycles have different periods, the peaks of the three cycles generally occur at different times. We would like to determine when a triple peak occurs (the peaks of all three cycles occur in the same day) for any person. For each cycle, you will
be given the number of days from the beginning of the current year at which one of its peaks (not necessarily the first) occurs. You will also be given a date expressed as the number of days from the beginning of the current year. You task is to determine
the number of days from the given date to the next triple peak. The given date is not counted. For example, if the given date is 10 and the next triple peak occurs on day 12, the answer is 2, not 3. If a triple peak occurs on the given date, you should give
the number of days to the next occurrence of a triple peak.
Input
peak, respectively. The value d is the given date and may be smaller than any of p, e, or i. All values are non-negative and at most 365, and you may assume that a triple peak will occur within 21252 days of the given date. The end of input is indicated by
a line in which p = e = i = d = -1.
Output
Case 1: the next triple peak occurs in 1234 days.
Use the plural form ``days'' even if the answer is 1.
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. 解题思路:中国剩余定理 源代码:#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<ctime>
using namespace std; typedef long long ll;
int num = 21252;
int main()
{
int p,e,i,d;
int n;
int index = 1;
while(scanf("%d%d%d%d",&p,&e,&i,&d)!=EOF)
{
if(p==-1&&e==-1&&i==-1&&d==-1)
break;
n=(5544*p+14421*e+1288*i-d+num)%num;
if(n==0)
n=num;
printf("Case %d: the next triple peak occurs in %d days.\n",index++,n);
}
return 0;
}
POJ1006-Biorhythms的更多相关文章
- POJ1006 Biorhythms —— 中国剩余定理
题目链接:https://vjudge.net/problem/POJ-1006 Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total ...
- POJ1006——Biorhythms(中国剩余定理)
Biorhythms Description人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色. ...
- 【学习笔记-中国剩余定理】POJ1006 Biorhythms
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 139500 Accepted: 44772 Des ...
- POJ1006 - Biorhythms(中国剩余定理)
题目大意 略...有中文... 题解 就是解同余方程组 x≡(p-d)(mod 23) x≡(e-d)(mod 28) x≡(i-d)(mod 33) 最简单的中国剩余定理应用.... 代码: #in ...
- POJ-1006 Biorhythms
[题目描述] 三个周期时间分别为:23,28和33.分别给定三个周期的某一天(不一定是第一天),和开始计算的日期,输出下一个triple peak. [思路分析] 如果不了解中国剩余定理,可以通过模拟 ...
- POJ1006 Biorhythms【中国剩余定理】
<题目链接> 题目大意: 人体的体力每23天会达到峰值,情感每28天会达到峰值,智力每33天会达到峰值,一个人在a天体力达到峰值,b天情感达到峰值,c天智力达到峰值,求这个人下一次体力情感 ...
- poj2891 Strange Way to Express Integers poj1006 Biorhythms 同余方程组
怎样求同余方程组?如: \[\begin{cases} x \equiv a_1 \pmod {m_1} \\ x \equiv a_2 \pmod {m_2} \\ \cdots \\ x \equ ...
- Biorhythms(中国剩余定理)
http://shuxueshi.jie.blog.163.com/blog/static/13611628820104179856631/ 这篇博客写的很棒! #include<stdio.h ...
- Biorhythms(poj1006+中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 117973 Accepted: 37026 Des ...
- poj1006 / hdu1370 Biorhythms (中国剩余定理)
Biorhythms 题意:读入p,e,i,d 4个整数,已知(n+d)%23=p; (n+d)%28=e; (n+d)%33=i ,求n . (题在文末) 知识点:中国剩余定理 ...
随机推荐
- GET_DDL提取目标元数据:ddl
创建对象的语句就是了 提取表 set line 200 pages 50000 wrap on long 999999 serveroutput on SQL> select dbms_meta ...
- Oracle官方非托管Odac驱动与Oracle官方托管odac驱动
方便自己,方便他人,记一次连接oracle的经历,使用 [Oracle官方非托管Odac驱动,Oracle.DataAccess.Client]连接数据库的时候程序会报错,找了很久都不知道是什么原因, ...
- hive1.2.2部署
1.解压hvie.tar,进入conf目录下,cp hive-default.xml.template hive-site.xml; 2.将hive下的新版本jline的JAR包拷贝到hadoop下: ...
- 全局作用域 eval
eval是在caller的作用域里运行传给它的代码: var x = 'outer'; (function() { var x = 'inner'; eval('x'); // & ...
- 使用TP5创建一个REST API
原文在这里 : http://hmw.iteye.com/blog/1190827 tp自带的api,get请求接口 /** * 显示资源列表 * * @return \think\Response ...
- PHP读取数据库表显示到前台
<?php$username=$_GET['uid']; //获取一个值作为查询条件 $result=$db->query("select * from trip where a ...
- 通讯框架 t-io 学习——websocket 部分源码解析
前言 前端时间看了看t-io的websocket部分源码,于是抽时间看了看websocket的握手和他的通讯机制.本篇只是简单记录一下websocket握手部分. WebSocket握手 好多人都用过 ...
- 利用java的net包来实在数据采集的功能
最近有好多朋友问我,数据抓取用java怎么做,就是每天把新浪的内地新闻频道的新闻前20条,抓到自己的网站或系统里,今天我统一在这里提供一个简单的例子,由于在这个过程中还需要解析html字符串,所以,我 ...
- Mac上配置不同版本的JDK
Mac上JDK的版本为1.8,编译AOSP时发现需要JDK 1.7.想找一种比较容易切换JDK版本的方式,经过一番Google发现Jenv比较合适. 安装Jenv至少有三种方式: - $ git cl ...
- 在moba游戏里面模拟实现绝地求生毒雾圈功能
---恢复内容开始--- 已经有很长一段时间没做项目了上半年大多数时间都荒废在王者荣耀,哈哈,S8赛季也上了王者,美滋滋 转回正题,公司需要开个新项目,需要把原有的moba游戏,改成类似绝地求生那玩法 ...