# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22628 | 현우야 이거 플로우야 (#40) | Fully Generate (KRIII5_FG) | C++11 | 0 ms | 1308 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 <map>
using namespace std;
map<long long, long long> dp;
int maxi = 2;
long long gol(long long n) {
long long sum = dp[1];
long long i;
for (i = 2; i <= n; i++) {
dp[i] = 1 + dp[i - dp[dp[i - 1]]];
sum += dp[i];
if (sum >= n) break;
}
return i;
}
long long gal(long long n) {
n++;
if (n % 2) return (2 * n * n - 2) / 8;
return n * n / 4;
}
long long pow(long long a, long long n) {
if (n == 0) return 1;
if (n == 1) return a;
if (n % 2) return a * pow(a, n - 1) % 1000000007;
long long r = pow(a, n / 2);
return r * r % 1000000007;
}
int main() {
dp[1] = 1;
long long n;
scanf("%lld", &n);
if (n == 1) {
printf("1\n");
return 0;
}
long long ans = 1;
long long g = gol(n);
for (int i = 2; i < g; i++)
ans = (ans * pow(i, i / 2 + 1)) % 1000000007;
for (int i = 0; i <= n - gal(g); i++)
ans = (ans * g) % 1000000007;
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |