luogu#P8104. 「LCOI2022」 Cow Function
「LCOI2022」 Cow Function
Background
Bessie and the others are sitting in the newly merged barn, studying loop unrolling with Farmer John.
Farmer John says that if the unrolling step size is , it can greatly improve program efficiency.
After class, Farmer John assigned a problem: compute within second. Bessie wrote a program in minutes, but it got TLE right after submission. So Bessie came to you for help.
Problem Description
She wants to compute, for , the value of $f(n)=\sum_{i=1}\limits^n[\omega(i)\equiv k\pmod 8]3^{\omega(i)}$.
In the formula above, denotes how many distinct prime factors has. For example, .
Input Format
A single line containing an integer .
Output Format
Output lines. The -th line (for ) should output the value of $f(n)=\sum_{i=1}\limits^n[\omega(i)\equiv k \pmod 8]3^{\omega(i)}$.
30
1
48
108
27
0
0
0
0
114514
1
32826
344727
1199826
1504818
538731
25515
0
Hint
Constraints
| subtask | points | time limit | |
|---|---|---|---|
If you need a loop unrolling generator, please download it from the attachment.
Translated by ChatGPT 5