|
Yuuka |
Ugh... Uuugh... |
|
Yuuka |
Not that robot... Firing anti-tank missiles isn't an event in the sports festival... |
|
Yuuka |
Those vehicles cost so much to rent... And the damage claims from the other schools... |
|
Yuuka |
At this rate, we'll all go bankrupt...! |
|
Yuuka |
H-huh? Was it a dream...? |
|
|
The first line contains two positive integers , , separated by a space. ;
Print the number of sports events included in sports festival plan . Since the number can be very large, print its remainder modulo instead.
All sports events using at least two pieces of equipment, with the greatest common divisor of any two distinct equipment numbers equal to , are listed below.
Yuuka
|
Phew... Thank goodness. What a horrible nightmare... |
|
Yuuka |
I mean, Kivotos may have its share of strange students, but surely none of them would fire anti-tank missiles like fireworks at the festival for no reason... |
|
Yuuka |
Wait, why is it so bright outside? What time is it...? |
|
Yuuka |
Seven in the morning?!! |
|
Yuuka |
Oh no! There's still so much to prepare for the sports festival...! |
|
Yuuka |
First, I need to change into my tracksuit... No, those urgent notices need to go out first...! |
|
Yuuka |
S-sorry, Noa! I must have fallen asleep without realizing...! |
|
Noa |
Shh— |
|
Yuuka |
...H-huh? |
|
Noa |
Keep your voice down a little, Yuuka-chan. Everyone has only just fallen asleep. |
|
Yuuka |
O-oh... |
|
Noa |
Heehee. Everyone must be tired after working so late last night. |
The members of Veritas finished my work while I was asleep. All that's left now is the equipment management plan Noa gave me. Let's calculate this quickly and finish preparing for the sports festival.
I've numbered the sets of sports equipment for the events from to . A combination of equipment can be used to hold a sports event .
A sports event must satisfy the following conditions.
Now I need to make a sports festival plan consisting of several sports events . The conditions this plan has to satisfy are giving me a headache, so let me write them down.
Consider a sports festival plan containing as many sports events as possible. How many sports events would such a plan contain...? Noa did give me this task, but... Doesn't this sound more like an algorithm problem than an equipment management plan for the Kivotos Halo Festival? Wait! Noa! Where did you go!?
There is no sports event using more pieces of equipment than , so can be included in plan .
The sports event uses more pieces of equipment than each of .
Since , the events can be included in plan .
Therefore, plan contains sports events.
All sports events using at least two pieces of equipment, with the greatest common divisor of any two distinct equipment numbers equal to , are listed below.
There is no sports event using more pieces of equipment than , so can be included in plan . Therefore, plan contains sports event.
The sports events using the largest possible number of pieces of equipment are and . Including every combination of at least two pieces of equipment from either event in plan gives a total of distinct sports events.
For example, satisfies the conditions for a sports event, but no sports event uses all of its equipment together with additional equipment. However, regardless of whether it belongs to , an event using more pieces of equipment, such as , does exist. Thus, cannot be included in plan .