# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22503 | 최숭실 (#40) | Fully Generate (KRIII5_FG) | C++11 | 309 ms | 313616 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>
#include <queue>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
#define MOD 1000000007
long long pow(long long n, long long k) {
if (k == 0) return 1;
if (k == 1) return n%MOD;
long long ret = pow(n, k / 2);
ret = ret * ret % MOD;
if (k & 1) ret = ret * n % MOD;
return ret;
}
long long count(long long from, long long to) {
}
long long dy[40000000];
int main() {
long long n;
scanf("%lld", &n);
long long ans = 1;
long long nu = 1;
long long i = 0;
long long pv = 0;
dy[1] = 1;
dy[2] = dy[3] = 2;
long long tot = 5;
nu = 4;
for (int i = 3; i < 40000000; i++) {
long long tmp = 1;
for (int j = nu; j < nu + dy[i] && j < 40000000; j++) {
dy[j] = i;
tot += i;
tmp = j * tmp % MOD;
}
nu += dy[i];
if (nu >= 40000000) break;
}
ans = 1;
nu = 0;
tot = 1;
for (i = 1; nu <= n; i++) {
pv = dy[i];
if (nu + pv > n) break;
tot = tot * i % MOD;
if (dy[i] != dy[i + 1]) {
ans = ans * pow(tot, pv) % MOD;
tot = 1;
}
nu += pv;
}
n -= nu;
ans = ans * pow(tot, dy[i - 1]) % MOD;
ans = ans * pow(i, n) % MOD;
printf("%lld\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |