luogu#P7571. 「MCOI-05」幂积
「MCOI-05」幂积
Background
Bookworm has gold medals.
Bookworm is organizing his gold medals. His medals have four types, in order: NOI gold medal, IOI gold medal, IMO gold medal, ICPC WF gold medal. On day to day , he ACs a contest each day and gets one gold medal of one of the types above. For a given parameter , the value of the gold medal obtained on day is if , and if .
Every day, Bookworm uses some magical method to choose which contest to AC that day. For day , let , where are all primes. Bookworm computes , where is the remainder of modulo , and then ACs the -th type of contest, obtaining a gold medal of the -th type.
Bookworm has too many medals, so he invites you to help him compute, among these medals, the sum of values in each type. But Bookworm is not satisfied with that. He gives you and , and asks you to compute the answer for each when .
Problem Description
Define the function , where are primes. In particular, .
For , define the function as:
Given and , for all , compute for all .
Input Format
The first line contains a positive integer .
The second line contains a non-negative integer .
Output Format
Output lines.
The -th line contains four non-negative integers, and the -th non-negative integer is .
10 0
2 2 3 3
2 1 1 1
1 0 1 1
Hint
Explanation of Sample 1
Constraints
This problem uses bundled testdata.
| Subtask | Score | ||
|---|---|---|---|
| 1 | 5 pts | None | |
| 2 | 15 pts | ||
| 3 | 25 pts | None | |
| 4 | None | ||
| 5 | 30 pts | None |
For of the testdata, and .
Translated by ChatGPT 5