The math koishi
Topic links: math koishi of
Subject to the effect
Give you a formula that allows you to find the results (detailed look at the subject link inside)
Topic solution to a problem
If out of this problem, I would be dead (really
Looked at, it will not hit the table. What hit the table for a long time did not find, because \ (n \) are changing, not the same answer every time, and then I changed the idea, for every number on the for \ (n \) different is how change You get it?
So I do not count for each table and punched (x behalf
1 -> 0 1 2 3 4 5 6 7 8 9
2 -> x 2 4 6 8 10 12 14 16
3 -> x x 1 4 7 10 13 16 19 22
4 -> x x x 1 5 9 13 17 21 25
5 -> x x x x 4 9 14 19 24 29
6 -> x x x x x 3 9 15 21 27
7 -> x x x x x x 8 15 22 29
8 -> x x x x x x x 8 16 24
9 -> x x x x x x x x 12 21
10 -> x x x x x x x x x 13
Then we found that for every one, the first one does not know how come, then followed each and every one plus from the former \ (i \) obtained
Then it is obvious, as long as we get the first one will be able to convert the final answer by the O (1) equation, but apparently this is not so good the first request, had wanted to hit the table, but ran a very long time did not run out, and then wanted the other way (see explanations)
Finally found a way to the first solution to a problem is a bit like this, I looked oh! The original can be
For each fixed \ (i \) , \ (the X-\) when incremental \ (the X-- (xMODi) \) , which is every \ (i \) key to increase \ (i \) of a series, because the we hit the table above are available, each of which is obtained from a former, we can think of as it should be recursive
Code is as follows (this title quq I still less write it)
//#define fre yes
#include <cstdio>
const int N = 1000005;
long long n, ans, tag[N];
int main() {
static int n;
scanf("%lld", &n);
for (int i = 2; i <= n; i++) {
for (int j = i; j <= n; j += i) {
tag[j] += i;
}
}
for (int i = 1; i <= n; i++) {
ans += n - tag[i] - 1;
printf("%lld ", ans);
} return 0;
}