

実行時間制限: 6 sec / メモリ制限: 1024 MB
配点 : 点
問題文
整数 が与えられます。整数列 が次の条件をすべて満たすとします。
- 。
- 任意の () に対して、 は の倍数である。
- は狭義単調増加である。つまり、 が成り立つ。
として考えられる最小値を、 で割った余りを求めてください。
個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
入力
入力は以下の形式で標準入力から与えられます。
各テストケースは以下の形式で与えられます。
出力
行出力してください。 行目には、 に対する答えを出力してください。
入力例 1Copy
5 5 100 1 10 10 1 1000000000000000000 1 100 100
出力例 1Copy
525 10 55 75433847 61074
はじめの つのテストケースについて、例えば次の が の最小値を与えます:
- 番目のテストケース:。
- 番目のテストケース:。
- 番目のテストケース:。
Score : points
Problem Statement
You are given integers and . Assume that an integer sequence satisfies all of the conditions below.
- .
- For every (), is a multiple of .
- is strictly increasing. In other words, holds.
Find the minimum possible value of , modulo .
There are test cases, each of which should be solved.
Constraints
Input
Input is given from Standard Input from the following format:
Each case is in the following format:
Output
Print lines. The -th line should contain the answer for .
Sample Input 1Copy
5 5 100 1 10 10 1 1000000000000000000 1 100 100
Sample Output 1Copy
525 10 55 75433847 61074
Here is a sequence that minimizes for each of the first three test cases.
- The first test case: .
- The second test case: .
- The third test case: .