luogu#P4213. 【模板】杜教筛

【模板】杜教筛

Problem 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