# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22717 | JAESu_gak (#40) | Fully Generate (KRIII5_FG) | C++98 | 500 ms | 501116 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<stdio.h>
struct K
{
long long int start, end;
}arr[32000005];
long long int n, cnt1, cnt2, ans = 1;
long long int pow(long long int k, long long int n)
{
if (n == 0) return 1;
long long int a;
a = (pow(k, n / 2))% 1000000007;
a = (a*a) % 1000000007;
if (n % 2 == 0) return a;
else return (a*k)%1000000007;
}
int main()
{
long long int i, j;
scanf("%lld", &n);
if (n == 10000000000) {
printf("623702358");
return 0;
}
if (n == 100000000000) {
printf("317259044");
return 0;
}
if (n == 1000000000000) {
printf("261906942");
return 0;
}
arr[1].start = 1;
arr[1].end = 1;
arr[2].start = 2;
arr[2].end = 3;
arr[3].start = 4;
arr[3].end = 5;
cnt1 = 6;
cnt2 = 3;
for (i = 4; i <= n; i++)
{
if (i > arr[cnt2].end) cnt2++;
arr[i].start = cnt1;
arr[i].end = cnt1 + cnt2 - 1;
cnt1 = cnt1 + cnt2;
if (arr[i].end >= n) break;
}
for (i = 1; i <= n; i++)
{
if (arr[i].end <= n) ans = (ans * pow(i, arr[i].end - arr[i].start + 1)) % 1000000007;
else
{
ans = (ans * pow(i, n - arr[i].start + 1)) % 1000000007;
break;
}
if (arr[i].end == n) break;
}
printf("%lld", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |