当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4188:Coin Collecting

题目描述
As a member of the Association of Coin Minters (ACM), you are fascinated by all kinds of coins and one of your hobbies involves collecting national currency from diff erent countries. Your friend, also an avid coin collector, has her heart set on some of your precious coins and has proposed to play a game that will allow the winner to acquire the loser's collection (or part thereof).
She begins by preparing two envelopes, each of them enclosing two coins that come from di fferent countries. Then she asks you to choose one of the two envelopes. You can see their contents before making your choice, and also decline the off er and take neither. This process is repeated for a total of r times. As the game progresses, you are also allowed to change your mind about your previous picks if you think you can do better. Eventually, your friend examines the envelopes in your fi nal selection, and from among them she picks a few envelopes herself. If her selection is non-empty and includes an even number of coins from every country (possibly zero), she wins and you must hand over your entire coin collection to her, which would make years of painstaking eff ort go to waste and force you to start afresh. But if you win, you get to keep the coins from all the envelopes you picked.
Despite the risks involved, the prospect of enlarging your collection is so appealing that you decide to take the challenge. You'd better make sure you win as many coins as possible.
输入解释
The fi rst line of each test case is the number r of rounds (1<=r<=300); a line with r = 0 indicates the end of the input. The next r lines contain four non negative integers 0<=a,b,c,d<10,000, meaning that your friend puts coins from countries labelled a and b inside one of the envelopes, and c and d inside the
other one. A blank line separates test cases.
输出解释
Print a line per test case containing the largest number of coins you are guaranteed.
输入样例
4
0 1 0 5
5 1 0 5
1 2 0 1
1 5 2 0

6
1 4 1 4
2 4 2 4
0 3 0 3
0 4 0 4
4 3 4 3
1 3 1 3

0
输出样例
6
8
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 SWERC 2011

源链接: HDU-4188

最后修改于 2020-10-25T23:11:05+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/10000MS(Java/Others) 65536/32768K(Java/Others)