#P6156. 简单题

    ID: 5035 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2020莫比乌斯反演块状链表,块状数组,分块差分

简单题

Description

Given n,kn, k, 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, gcd(i,j)\gcd(i,j) denotes the greatest common divisor of ii and jj.

The function ff is defined as follows:

If kk has a square factor, then f(k)=0f(k)=0; otherwise, f(k)=1f(k)=1.

Update: Definition of a square factor. If there exists an integer k(k>1)k(k>1) such that k2nk^2 \mid n, then kk is a square factor of nn.

Output the answer modulo 998244353998244353.

Input Format

One line containing two integers n,kn, k.

Output Format

One line containing one integer, meaning the value of the answer modulo 998244353998244353.

3 3
1216
2 6
9714
18 2
260108
143 1
7648044

Hint

Test Point nn kk
1,21,2 103\leq10^3
3,43,4 2×103\leq2 \times 10^3 1018\leq10^{18}
585 \sim8 5×104\leq5 \times 10^4
99 5×106\leq 5\times10^6 =1=1
10,1110,11 =2=2
12,1312,13 103\leq10^3
142014 \sim20 1018\leq10^{18}

For 100%100\% of the testdata, 1n5×1061 \leq n \leq 5 \times 10^6, 1k10181 \leq k \leq 10^{18}.

Update on 2020/3/16:

The time limit was changed to 11s, ruling out solutions of O(nlogk)O(n\log k) and O(nlogmod)O(n\log mod).

Translated by ChatGPT 5