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

建议使用的浏览器:

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

7240:Shortest Path in GCD Graph

题目描述
There is an edge-weighted complete graph $K_n$ with $n$ vertices, where vertices are labeled through $1,2,...,n$.
For each $1\leq i\lt j\leq n$, the weight of the edge $(i,j)$ between $i$ and $j$ is $gcd(i,j)$, the greatest common divisor of $i$ and $j$.

You need to answer $q$ queries. In each query, given two vertices $u,v$, you need to answer the <strong> length of the shortest path</strong> as well as the <strong>number of shortest paths</strong> between $u,v$. Since the <strong>number of shortest paths</strong> may be too large, you only need to output it modulo $998244353$.
输入解释
The first line contains two integers $n,q(2\leq n \leq 10^7,1\leq q\leq 50000)$, denoting the number vertices in the graph and the number of queries, respectively.

Then $q$ lines follow, where each line contains two integers $u,v(1\leq u,v\leq n,u\neq v)$, denoting a query between $u$ and $v$.
输出解释
For each query, output one line contains two integers, denote the length and number of shortest path between given nodes, respectively. Note that only the <strong>number of shortest paths</strong> should be taken modulo $998244353$.
输入样例
6 2
4 5
3 6
输出样例
1 1
2 2

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

源链接: HDU-7240

最后修改于 2022-09-15T06:17:35+00:00 由爬虫自动更新

共提交 0

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