本文共 1405 字,大约阅读时间需要 4 分钟。
The task at hand is to determine the winning number in a unique lottery system designed for Martian inhabitants. The game works by participants betting on numbers from a specific range, and the winner is the first to bet on a unique number not previously chosen.
Each test case consists of a line starting with an integer N
(≤ 10^5), followed by N
bets. These bets are separated by spaces. The output should be the winning number only if there is one. If no unique number exists after all bets, return "None".
Input:
7 5 31 5 88 67 88 17The program processes each bet, keeping track of each number. The first unique number is "31", so it is printed.Output:
31Input:
5 888 666 666 888 888In this case, the bets go 5 times. The program counts occurrences: 888 appears 3 times, 666 appears 2 times, and both have duplicates. Thus, no unique winner exists, and the output is "None".The provided C++ implementation uses an efficient array-based approach to track bets:
This approach ensures that the solution is both simple and efficient, handling up to the maximum constraints smoothly.
转载地址:http://qahgz.baihongyu.com/