Ransom
Time limit2sMemory limit1024 MB
Find the hidden population of each of n cities by asking at most n queries, each returning the product of a chosen subset.
- Level
Medium6 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
This is an interactive problem.
After Baldr was killed, Odin decided to bring him back to Asgard from Helheim, the realm of the dead. He gave his horse Sleipnir to Hermod and sent him to Hel, the goddess of the dead, to offer a ransom for Baldr. Hel agreed to release him if everything in the world, all things and creatures, wept for Baldr. That demand could not be met, so Hermod and Hel began discussing other ransom amounts.
Hermod said the world has cities, and every person living in them is ready to mourn Baldr. Let be the population of city . He refused to name the population of any city. He agreed to answer a few questions instead, each of the form: tell me the product , where are distinct indices of some of these cities. He allowed at most questions.
Help the ruler of the dead find how many people live in each city.
Hints
The number the judge returns after each query can be quite large.
For the program to work correctly, you must do the following after every output operation:
- Pascal:
flush(output); - C/C++:
fflush(stdout); - Java:
System.out.flush(); - Python:
sys.stdout.flush();
Also end every printed line with a newline character.