#P4213. 【模板】杜教筛

    ID: 3144 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学递推O2优化素数判断,质数,筛法前缀和块状链表,块状数组,分块

【模板】杜教筛

Description

Given a positive integer nn, compute

ans1=i=1nφ(i)ans_1=\sum_{i=1}^n\varphi(i) ans2=i=1nμ(i)ans_2=\sum_{i=1}^n \mu(i)

Input Format

This problem contains multiple test cases within a single test file.

The first line contains an integer, denoting the number of test cases TT.

Then TT lines follow, each containing an integer nn, representing one query.

Output Format

For each query, output two integers in one line, representing ans1ans_1 and ans2ans_2.

6
1
2
8
13
30
2333
1 1
2 0
22 -2
58 -3
278 -3
1655470 2

Hint

Constraints

For all test cases, it is guaranteed that 1T101 \leq T \leq 10, 1n<2311 \leq n \lt 2^{31}.

Translated by ChatGPT 5