# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
19872 | gs13068 | 팔찌 (kriii4_V) | C++98 | 932 ms | 12800 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
const int p = 1000000007;
int pw(int x, int y)
{
return y & 1 ? (long long)pw(x, y ^ 1)*x%p : y ? pw((long long)x*x%p, y >> 1) : 1;
}
int a[1000001];
int c[1000001];
int d[1000001];
int main()
{
int i, j, t1, t2, n, m, r = 0;
scanf("%d%d", &n, &m);
for (i = 1; i <= n; i++)
{
t1 = (a[i] + pw(m, i)) % p;
for (j = i; j <= n; j += i)
{
a[j] = (a[j] + p - t1) % p;
d[j] = (d[j] + (long long)t1*(j / i)) % p;
}
}
r = 2;
for (i = 1; i <= n; i++)
{
d[i] = (long long)d[i] * pw(i, p - 2) % p;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |