It was told by Scheherazade that far away,
in the middle of the desert, there is a lake. Originally this lake had F fish in it.
K different kinds of gemstones were chosen among
the most valuable on Earth, and to each of the F fish exactly one gem was given for it
to swallow. Note, that since K might be
less than F,
two or more fish might swallow gems of the same kind.
As time went by, some fish ate some of the other fish.
One fish can eat another if and only if it is at least
twice as long (fish A can eat fish B if
and only if LA >= 2 * LB). There is no rule as to when a fish decides to eat.
One fish might decide to eat several smaller fish one
after another, while some fish may decide not to eat any
fish, even if they can.
When a fish eats a smaller one, its length doesn't change,
but the gems in the stomach of the smaller fish
end up undamaged in the stomach of the larger fish.
Scheherazade has said that if you are able to find the
lake, you will be allowed to take out one fish and keep all the gems in its stomach for yourself. You are willing to try your luck, but before you head out on
the long journey, you want to know how many different combinations of gems you could obtain by
catching a single fish.
There are multiple test cases in the input file, and there is an integer T in the first line represent the total number of test cases. For each test case, your program must read from the standard input the following data:
For each test case, your program must write to the standard output a single line containing one integer between 0 and M-1 (inclusive): the number of different possible combinations of gemstones modulo M.
Note that for solving the task, the value of M has
no importance other than simplifying computations.
1 5 3 7 2 2 5 1 8 3 4 1 2 3
4
There are 11 possible combinations so you should output 11 modulo 7 which is 4.
The possible combinations are: [1] [1,2] [1,2,3] [1,2,3,3] [1,3] [1,3,3] [2] [2,3] [2,3,3] [3] and [3,3].
<li> [2,3,3]: Third eats first, third eats fifth, you catch it.
Migrated from old NTUJ.
IOI2008
No. | Testdata Range | Score |
---|