当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6889:Graph Theory Class

题目描述
This class is on graph theory. Mr. Kruskal teaches babies the concept of minimal spanning tree, and how to calculate the minimal spanning tree of a given graph.

Now, it's time for an in-class quizz. Mr. Kruskal shows a special graph $G$: $G$ is a complete undirected graph with $n$ vertices, and vertices in $G$ are indexed from $1$ to $n$. The weight of the edge between the $i$th vertex and the $j$th vertex is equal to $lcm(i+1,j+1)$. Babies are asked to find the minimal spanning tree of $G$.

As a super baby, Baby Volcano quickly finds an answer, but he is not sure on the correctness of his answer. Your task is to tell Baby Volcano the weight sum of all edges on the minimal spanning tree, so that he could verify his answer.

Given two positive integers, $lcm(i,j)$ is defined as the minimal positive integer $k$ satisfying both $i$ and $j$ are factors of $k$.
输入解释
The first line contains a single integer $t (1 \leq t \leq 50)$, the number of testcases.

For each testcase, the first line contains two integers $n, K (1 \leq n \leq 10^{10}, 10^8 \leq K \leq 10^9)$.

The input guarantees that $K$ is a prime number.

The input guarantees that there are no more than $5$ testcases with $n > 10^9$.
输出解释
For each testcase, output a single line with a single integer, the answer module $K$.
输入样例
3
3 998244353
100 998244353
1000000000 998244353
输出样例
10
6307
192026508
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6889

最后修改于 2020-10-25T23:35:17+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
14000/7000MS(Java/Others) 524288/524288K(Java/Others)