[Solution] Fishermen Codeforces Solution
There are fishermen who have just returned from a fishing trip. The -th fisherman has caught a fish of size .
The fishermen will choose some order in which they are going to tell the size of the fish they caught (the order is just a permutation of size ). However, they are not entirely honest, and they may "increase" the size of the fish they have caught.
Formally, suppose the chosen order of the fishermen is . Let be the value which the -th fisherman in the order will tell to the other fishermen. The values are chosen as follows:
- the first fisherman in the order just honestly tells the actual size of the fish he has caught, so ;
- every other fisherman wants to tell a value that is strictly greater than the value told by the previous fisherman, and is divisible by the size of the fish that the fisherman has caught. So, for , is the smallest integer that is both strictly greater than and divisible by .
For example, let , . If the chosen order is , then:
- ;
- is the smallest integer divisible by and greater than , which is ;
- is the smallest integer divisible by and greater than , which is ;
- is the smallest integer divisible by and greater than , which is ;
- is the smallest integer divisible by and greater than , which is ;
- is the smallest integer divisible by and greater than , which is ;
- is the smallest integer divisible by and greater than , which is .
You have to choose the order of fishermen in a way that yields the minimum possible .
The first line contains one integer () — the number of fishermen.
The second line contains integers ().
Print one integer — the minimum possible value of you can obtain by choosing the order of fishermen optimally.
No comments:
Post a Comment