Submission #22717

#TimeUsernameProblemLanguageResultExecution timeMemory
22717JAESu_gak (#40)Fully Generate (KRIII5_FG)C++98
2 / 7
500 ms501116 KiB
#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)

FG.cpp: In function 'int main()':
FG.cpp:18:19: warning: unused variable 'j' [-Wunused-variable]
  long long int i, j;
                   ^
FG.cpp:19:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...