#P6156. 简单题
简单题
Background
zbw ran into a problem. Since he is in a hurry to meet qby, he wants you to solve it for him.
Problem Description
Given , find the value of the following expression:
$\sum\limits_{i=1}^n\sum\limits_{j=1}^n(i+j)^k f(\gcd(i,j)) \gcd(i,j)$
Here, denotes the greatest common divisor of and .
The function is defined as follows:
If has a square factor, then ; otherwise, .
Update: Definition of a square factor. If there exists an integer such that , then is a square factor of .
Output the answer modulo .
Input Format
One line containing two integers .
Output Format
One line containing one integer, meaning the value of the answer modulo .
3 3
1216
2 6
9714
18 2
260108
143 1
7648044
Hint
| Test Point | ||
|---|---|---|
For of the testdata, , .
Update on 2020/3/16:
The time limit was changed to s, ruling out solutions of and .
Translated by ChatGPT 5