# | Problem | Pass Rate (passed user / total user) |
---|---|---|
12883 | Patrick and Spongebob in SAO |
|
13587 | To Binary (II) |
|
13590 | smart little kai |
|
Description
UPD(2020/10/12 14:42): We update the description (new part added are in red word) for more clearly. Sorry for the inconvenience.
Spongebob and Patrick finally find out the guy with the biggest nose. But unluckily the guy is not Squidward (actually he is Barnacle Boy).
Suddenly, they see some octopus flies over.
“Well, we know one thing: it sure isn’t that guy.” said Spongebob.
Anyway Patrick is very hungry so they go to the restaurant, SAO(Seafood Around Octopuses), for their dinner. After arrving SAO, they order one Ragout Rabbit first.
They quickly eat up the Ragout Rabbit. But now they're facing a problem: they don’t know what they should order next. Patrick suggests that they could order the dish which is ordered by other customers mostly. So it’s your turn again!
There are n customers in SAO (of course not include Spongebob, Patrick and you) and they are numbered from 1 to n. Each of them orders exactly one dish. The dish ordered by the i-th customer is represented by an integer ai(the dish's number on the menu). You need to tell Spongebob and Patrick which dish is ordered mostly between the l-th, the (l+1)-th, …, the r-th customers. And if there are not only one kind of dish ordered mostly, you just need to output the dish's number which is the smallest between all the dishes ordered mostly in the range.
You have to help Spongebob and Patrick q times.
Subtask
- for testcase 1~2: ai = 1
- for testcase 3~5: ai = 1 or ai = 2
- for testcase 6~10: no additional restriction
Input
The first line contains one integer n (1 ≤ n ≤ 500) – the number of customers in SAO.
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 500) – the number of dish each customer order.
The third line contains one integer q (1 ≤ q ≤ 500) – the times you have to help Spongebob and Patrick.
Then q lines follow. Each line contains two integer l, r (1 ≤ l ≤ r ≤ n) – the range of customers you have to find out the dish ordered mostly.
Output
For each time you help Spogebob and Patrick, output the dish's number which is ordered mostly in the range of customers(if there are not only one kind of dish ordered mostly, you just need to output the dish's number which is the smallest between all the dishes ordered mostly in the range).
Remember to print a newline('\n') at the end of the last line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a nonnegative decimal number, please convert it to a binary representation.
For example, given 3, please print 11; given 16, please print 10000.
Hint:
We need 31 bit to represent all the nonnegative integer.
Input
A nonnegative decimal integer D.
Output
A binary presentation of D.
Note that you have to print "\n" in the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Little kai is so smart that his mama needs to give him more challenging tricks for a treat.
Now he needs to figure out if a number is a very special number.
A very special number is a number whose sum of its digits powered to the number of its digits is equal to the number itself.
For example:
153, because 153 = 13 + 53 + 33
1634, because 1634 = 14 + 64 + 34 + 44
54748, because 54748 = 55 + 45 + 75 + 45 + 85
Input
Commands separated by a newline character.
Note that:
Each command is a positive integer n
0 < n < 109
Output
If it is a very special number, output "Yes it is."
If not, output "No it is not."
You need to print a newline character at the end of each line. ('\n')