# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22331 | ↓우리보다잘하는팀 (#40) | Fully Generate (KRIII5_FG) | C++14 | 316 ms | 126116 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 N = 32000000, p = 1000000007;
int a[N + 1];
int f(int x, int y) {
return y ? y & 1 ? 1ll * f(x, y ^ 1) * x % p : f(1ll * x * x % p, y >> 1) : 1;
}
int main() {
long long n;
int i, j, k, m, r;
scanf("%lld", &n);
a[1] = 1;
a[2] = 2;
for (i = j = 1; j <= N; i++) for (k = 0; k < a[i] && j <= N; k++) a[j++] = i;
for (i = 1; i <= N; i++) {
if (a[i] < n) n -= a[i];
else {
a[i] = n;
n = 0;
break;
}
}
r = f(i, a[i]);
j = 1;
while (--i) {
j = 1ll * j * i % p;
if (a[i] != a[i - 1]) r = 1ll * r * j % p;
}
printf("%d", r);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |