POJ 1044: Date bugs
题目描述
way, when 2^32 seconds (about 136 Years) have elapsed, the date will jump back to whatever the fixed date is.
Now, what can you do about all that mess? Imagine you have two computers C1 and C with two different bugs: One with the ordinary Y2K-Bug (i. e. switching to a1 := 1900 instead of b1 := 2000) and one switching to a2 := 1904 instead of b2 := 2040. Imagine that the C1 displays the year y1 := 1941 and C2 the year y2 := 2005. Then you know the following (assuming that there are no other bugs): the real year can't be 1941, since, then, both computers would show the (same) right date. If the year would be 2005, y1 would be 1905, so this is impossible, too. Looking only at C1 , we know that the real year is one of the following: 1941, 2041, 2141, etc. We now can calculate what C2 would display in these years: 1941, 1905, 2005, etc. So in fact, it is possible that the actual year is 2141.
To calculate all this manually is a lot of work. (And you don't really want to do it each time you forgot the actual year.) So, your task is to write a program which does the calculation for you: find the first possible real year, knowing what some other computers say (yi) and knowing their bugs (switching to ai instead of bi ). Note that the year ai is definitely not after the year the computer was built. Since the actual year can't be before the year the computers were built, the year your program is looking for can't be before any ai .
输入
The input is terminated by a test case with n = 0. It should not be processed.
输出
样例输入
2
1941 1900 2000
2005 1904 2040
2
1998 1900 2000
1999 1900 2000
0
样例输出
Case #1:
The actual year is 2141. Case #2:
Unknown bugs detected.
分析:毒瘤日期题,好好算,多调试。。。
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
int y[],a[],t[],n,cas;
void init(){ }
void solve(){
while(cin>>n,n){
range(i,,n-){
cin>>y[i]>>a[i]>>t[i];
t[i]-=a[i];
}
int ans=;
while((a[]=y[]+ans*t[])<){
bool flag=true;
range(i,,n-){
int tmp=a[]-y[i];
if(tmp<||tmp%t[i]){
flag=false;
break;
}
}
if(flag){
cout<<"Case #"<<++cas<<":"<<endl;
cout<<"The actual year is "<<a[]<<"."<<endl<<endl;
break;
}
++ans;
}
if(a[]>=){
cout<<"Case #"<<++cas<<":"<<endl;
cout<<"Unknown bugs detected."<<endl<<endl;
}
}
}
int main() {
init();
solve();
return ;
}
POJ 1044: Date bugs的更多相关文章
- OpenJudge / Poj 1044 Date bugs C++
链接地址: Poj:http://poj.org/problem?id=1044 OpenJudge:http://bailian.openjudge.cn/practice/1044/ 题目: 总时 ...
- POJ1044 Date bugs
题目来源:http://poj.org/problem?id=1044 题目大意: 与众所周知的”千年虫“类似,某些计算机上存在日期记录的bug.它们的时钟有一个年份周期,每当到达最大值时,就会自动跳 ...
- poj 2096 Collecting Bugs - 概率与期望 - 动态规划
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- POJ 2449Remmarguts' Date 第K短路
Remmarguts' Date Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 29625 Accepted: 8034 ...
- POJ 2096 Collecting Bugs 期望dp
题目链接: http://poj.org/problem?id=2096 Collecting Bugs Time Limit: 10000MSMemory Limit: 64000K 问题描述 Iv ...
- 【CEOI2002】【Poj 1038】Bugs Integrated, Inc.
http://poj.org/problem?id=1038 发一下中文题面(今天考试直接被改了): 生记茶餐厅由于受杀人事件的影响,生意日渐冷清,不得不暂时歇业.四喜赋闲在家,整天抱着零食看电视,在 ...
- POJ 2096 Collecting Bugs (概率DP,求期望)
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- POJ 2096 Collecting Bugs
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 1716 Accepted: 783 C ...
- poj 2096 Collecting Bugs (概率dp 天数期望)
题目链接 题意: 一个人受雇于某公司要找出某个软件的bugs和subcomponents,这个软件一共有n个bugs和s个subcomponents,每次他都能同时随机发现1个bug和1个subcom ...
随机推荐
- Windows下安装PHP及开发环境配置
一.Apache 因为Apache官网只提供源代码,如果要使用必须得自己编译,这里我选择第三方安装包Apache Lounge. 1. 进入Apachelounge官方下载地址:http://www. ...
- Leetcode 671.二叉树中第二小的节点
二叉树中第二小的节点 给定一个非空特殊的二叉树,每个节点都是正数,并且每个节点的子节点数量只能为 2 或 0.如果一个节点有两个子节点的话,那么这个节点的值不大于它的子节点的值. 给出这样的一个二叉树 ...
- LDA学习笔记
线性判别分析(Linear Discriminant Analysis,简称LDA)是一种经典的线性学习方法.其思想非常朴素,设法将样例投影到一条直线上,使得同类样例的投影点尽可能接近,异类的样例的投 ...
- bitbucket相关操作
常见命令: git checkout -b develop master 创建Develop分支的命令 git checkout master 切换到Master分支 git merge --no-f ...
- python XlsxWriter创建Excel 表格
文档(英文) https://xlsxwriter.readthedocs.io/index.html 常用模块说明(中文) https://blog.csdn.net/sinat_35930259/ ...
- 华东交通大学2017年ACM双基程序设计大赛题解
简单题 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submissio ...
- PHP可变变量的简单使用
知识点: 可变变量:简单说就是将一个变量的值用作另外一个变量的命名上,例如$a = 'b';$$a就是$b HTML代码: <!doctype html> <html> < ...
- 路由器配置PPP协议 CHAP验证 PAP验证
路由器配置PPP协议 CHAP验证 PAP验证 来源 https://www.cnblogs.com/tcheng/p/5967485.html PAP是两次握手,明文传输用户密码进行认证:CHAP是 ...
- apache+mysql+php实现最大负载的方法
1. 生成静态html页面,squid反向代理,apache,MySQL的负载均衡. 2. 可以采取数据缓存的方法,我们通常在统计数据的时候,需要在原始数据的基础上经过计算等一系列操作,才会得到最终的 ...
- Struts2---ActionContext和ServletActionContext小结
转载自:http://www.cnblogs.com/tanglin_boy/archive/2010/01/18/1650871.html感谢原文作者的总结 1. ActionContext 在St ...