#P7571. 「MCOI-05」幂积

「MCOI-05」幂积

Description

Define the function f(piai)=aipif(\prod p_i^{a_i})=\sum a_ip_i, where pip_i are primes. In particular, f(1)=0f(1)=0.

For k{0,1}k\in\{0,1\}, define the function gg as:

g(n,k,r)=i=1nik[f(i)r(mod4)]g(n,k,r)=\sum_{i=1}^ni^k[f(i)\equiv r\pmod 4]

Given mm and kk, for all 1im1\le i\le\lfloor\sqrt m\rfloor, compute g(mi,k,r)g(\lfloor\frac mi\rfloor,k,r) for all 0r<40\le r<4.

Input Format

The first line contains a positive integer mm.
The second line contains a non-negative integer kk.

Output Format

Output m\lfloor\sqrt m\rfloor lines.
The ii-th line contains four non-negative integers, and the rr-th non-negative integer is g(mi,k,r)g(\lfloor\frac mi\rfloor,k,r).

10 0
2 2 3 3
2 1 1 1
1 0 1 1

Hint

Explanation of Sample 1

f=[0,2,3,0,1,1,3,2,2,3,]f=[0,2,3,0,1,1,3,2,2,3,\dots]

Constraints

This problem uses bundled testdata.

Subtask Score mm kk
1 5 pts 107\le 10^7 None
2 15 pts 109\le10^9 =0=0
3 25 pts None
4 109\le10^9 None
5 30 pts None

For 100%100\% of the testdata, 1m10101\le m\le10^{10} and 0k10\le k\le1.

Translated by ChatGPT 5