

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
以上 以下の整数からなる長さ の数列 を考えます。
そのようなものは 個ありますが、その全てについての の和を求めてください。
ただし、答えは非常に大きくなる可能性があるため、和を で割ったあまりを出力してください。
なお、 は の最大公約数を表します。
制約
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
出力
個の数列全てについての の和を で割ったあまりを出力せよ。
入力例 1Copy
3 2
出力例 1Copy
9
となるため、答えは です。
入力例 2Copy
3 200
出力例 2Copy
10813692
入力例 3Copy
100000 100000
出力例 3Copy
742202979
和を で割った余りを出力してください。
Score : points
Problem Statement
Consider sequences of length consisting of integers between and (inclusive).
There are such sequences. Find the sum of over all of them.
Since this sum can be enormous, print the value modulo .
Here denotes the greatest common divisor of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the sum of over all sequences, modulo .
Sample Input 1Copy
3 2
Sample Output 1Copy
9
Thus, the answer is .
Sample Input 2Copy
3 200
Sample Output 2Copy
10813692
Sample Input 3Copy
100000 100000
Sample Output 3Copy
742202979
Be sure to print the sum modulo .