排除日期计算的一个bug的算法,怎么利用C语言的程序编写出来的代码的过程的思想方法去做

Description

There are rumors that there are a lot of computers having a problem with the year 2000. As they use only two digits to represent the year, the date will suddenly turn from 1999 to 1900. In fact, there are also many other, similar problems. On some systems, a 32-bit integer is used to store the number of seconds that have elapsed since a certain fixed date. In this
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 .
Input

The input file contains several test cases, in which the actual year has to be calculated. The description of each case starts with a line containing an integer n (1 <= n <= 20), the number of computers. Then, there is one line containing three integers yi,ai,bi for each computer (0 <= ai <= yi < bi < 10000). yi is the year the computer displays, bi is the year in which the bug happens (i. e. the first year which can't be displayed by this computer) and ai is the year that the computer displays instead of bi .
The input is terminated by a test case with n = 0. It should not be processed.
Output

For each test case, output output the line "Case #k:", where k is the number of the situation. Then, output the line "The actual year is z.", where z is the smallest possible year (satisfying all computers and being greater or equal to u). If there is no such year less than 10000, output "Unkown bugs detected.". Output a blank line after each case.
Sample Input

2
1941 1900 2000
2005 1904 2040
2
1998 1900 2000
1999 1900 2000
0
Sample Output

Case #1:
The actual year is 2141.

Case #2:
Unknown bugs detected.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

12
git中比如修改bug为什么要在bug分支中修改再合并到master中
1
C#解析XML文件,有一个bug问题。
1
运动规划的伪代码程序看不懂程序的逻辑
1
运动规划的伪代码程序有一行代码有疑问
1
这是一个求n个数的最小公倍数的程序,哪位大哥能帮我找一下bug吗?
3
如何在 生产环境 找bug
1
关于bug的搜索的问题,用C语言的实现方式
1
C语言小游戏多次循环偶尔几次会出bug,求解?
1
急求解决,sourceInsight到处产生备份文件及莫名其妙的删除程序文件的问题
0
通过第三方平台创建的小程序无法使用扫码关注公众号组件吗?
0
二分搜索方面的一个复习试题,感觉比较困难,怎么利用 C 语言的办法和方式解决
1
C语言贪吃蛇总是莫名奇妙卡住,我应该如何调试?
0
关于堆栈知识点的运用,如何解决这个序列出入分配,采用C语言的实现
2
vue中vux里面的checker组件的一个bug怎么解决
2
求助一个自己写程序中的关于TreeSet同时去重和按加入顺序存储的bug。
1
gdb调试任何C语言代码都报错:not in executable format: File format not recognized
2
C++的string头文件有时在使用时会遇到一些罕见的bug,这些bug是什么?
2
C#反射加载程序集,调用提示找不着依赖程序集
1
圆圈和线段在坐标系上的计算,怎么采用C语言的程序的代码的编写的功能加以实现?
0
数据完整性的校验的问题,怎么利用C语言的程序编写过程的办法用程序编写的方式完成