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 ...
随机推荐
- 如何将现有的项目添加到远程的git库里面!
我们经常都会遇到这样的场景,就是将本地的一个项目同步到网上远程的git库里面.最近也遇到这样的问题,发现网上很少人讲到这个问题,但是这个问题是很多程序员遇到的版本库管理的最早的拦路虎. 我的远程是ht ...
- 【转载】Unity3D研究院之共享材质的巧妙用法(sharedMaterial效率问题)
如果你需要修改模型材质的颜色,或者是修改材质Shader的一些属性, 通常情况是用获取模型的Renderer组件,然后获取它的material属性. 举个简单的例子,修改颜色或者直接更换shader ...
- 斐波那契数列的三种C++实现及时间复杂度分析
本文介绍了斐波那契数列的三种C++实现并详细地分析了时间复杂度. 斐波那契数列定义:F(1)=1, F(2)=1, F(n)=F(n-1) + F(n-2) (n>2) 如何计算斐波那契数 F( ...
- LightGBM的并行优化--机器学习-周振洋
LightGBM的并行优化 上一篇文章介绍了LightGBM算法的特点,总结起来LightGBM采用Histogram算法进行特征选择以及采用Leaf-wise的决策树生长策略,使其在一批以树模型为基 ...
- 团队项目-第三次scrum 会议
时间:10.25 时长:30分钟 地点:线上 工作情况 团队成员 已完成任务 待完成任务 解小锐 根据初步讨论结果编写初步的api文档 编写project和projectGenerator类 陈鑫 采 ...
- vs 2012 未能找到与约束contractName Microsoft.VisualStudio.Utilities...匹配的导出
系统自动更新后,打开项目进行维护时,居然出错了,报的错误信息为“未能找到与约束contractName Microsoft.VisualStudio.Utilities...匹配的导出” 上网查了下, ...
- 【bzoj4898】[Apio2017]商旅 Floyd+分数规划+Spfa
题目描述 有n个点.m条边.和k种商品.第$i$个点可以以$B_{ij}$的价格买入商品$j$,并以$S_{ij}$的价格卖出.任何时候只能持有一个商品.求一个环,使得初始不携带商品时以某种交易方式走 ...
- 决策树与随机森林Adaboost算法
一. 决策树 决策树(Decision Tree)及其变种是另一类将输入空间分成不同的区域,每个区域有独立参数的算法.决策树分类算法是一种基于实例的归纳学习方法,它能从给定的无序的训练样本中,提炼出树 ...
- 基于WEB的机器人远程控制
1.前进后退左转右转控制: 2.视频传输,为了保证视频的流畅性,选择相机支持格式中图像最小,帧率最低的:并对视频进行处理,将15帧处理成5帧,从而降低传输数据量: 3.地图显示及导航控制: 地图在三维 ...
- hibernate用配置文件的方式实现orm
本文主要讲用配置文件的方式讲如何把一个对象和数据库中的表关联起来,其实用配置文件本质是和用注解的方式是一样的. 思路:1.写一个domain对象(如Person.java) 2.写这个domain对象 ...