eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Changlong`s bother

Changlong`s bother

Changlong is a handsome and clever boy and he is admired by many beautiful girls. Every day he received tens of thousands of letters form girls which express their intense desire to be his life companion. You see, Changlong is very tired of this and one day he get an idea to avoid this bother. He declares: Only those clever girls who can solve the problem below have the qualification to be his wife. Changlong's problem can be formulated like this: There is one interesting sequence of numbers \textbf{a_1}, \textbf{a_2}, ..., \textbf{a_n}, this sequence has a very attractive property that every number appears exactly \textbf{p} times except a particular number \textbf{t}, which occurs \textbf{q} times. How to extract this particular number \textbf{t} from this sequence? In order to let this problem more mysterious, Changlong assumes that the involved number \textbf{p}, \textbf{q} in his problem are prime to each other, i.e., \textbf{gcd(p, q)=1}. Changlong's method works very well. After his declaration, the number of received letter has decrease sufficiently. The girls are beginning to think over the problem with continuous strenuous effort, no sooner later they find this problem is beyond their ability. So most of them give up, but there is still a beautiful girl who is persistent in this problem. One day this girl comes across you and she invites you to help her. \InputFile At the first line of the input is a integer \textbf{k} (\textbf{0} < \textbf{k} ≤ \textbf{100}), the number of test cases. For each test case, there will be a line containing three integers: \textbf{n} (\textbf{0} < \textbf{n} ≤ \textbf{10^7}), \textbf{p}, \textbf{q} (\textbf{1} < \textbf{p}, \textbf{q} < \textbf{200}, \textbf{gcd(p,q)=1}) and a line containing \textbf{n} elements \textbf{a_i} (\textbf{0} < \textbf{a_i} < \textbf{10^7}) of the sequence. \OutputFile For each test case, you should first output a line with "\textbf{Case #:}", where \textbf{#} is the \textbf{id} of the test case, then you should output the particular number \textbf{t}, i.e., the number which occurs \textbf{q} times in the sequence.
Лимит времени 10 секунд
Лимит использования памяти 16 MiB
Входные данные #1
2
8 3 2
1 2 1 2 1 2 3 3
7 4 3
1 1 1 1 2 2 2
Выходные данные #1
Case 1:
3
Case 2:
2
Источник Hunan University 2011 the 7th Programming Contest