Submission #22407

#TimeUsernameProblemLanguageResultExecution timeMemory
22407Jongwon Party (#40)Fully Generate (KRIII5_FG)C++14
7 / 7
229 ms1520 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; long long g[52000]; const int mod = 1000000007; int e(int a, int x) { if(x == 0) return 1; if(x%2) return 1LL * a * e(a, x-1) % mod; int t = e(a, x/2); return 1LL * t * t % mod; } int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); long long c, n, j; int p, x, r, t, i; scanf("%lld", &n); g[1] = 1; g[2] = 3; p = 2; c = 5; for(i = 3;; i++) { while(g[p] < i) p++; g[i] = g[i-1] + p; c += i * (g[i] - g[i-1]); if(c >= n) break; } x = i; r = 1; c = 0; t = 1; for(i = 1; i<=x; i++) { for(j = g[i-1]+1; j<=g[i]; j++) { if(c + i >= n) { r = 1LL * r * e(t, i) % mod; r = 1LL * r * e(j % mod, n-c) % mod; printf("%d", r); return 0; } t = 1LL * t * j % mod; c += i; } r = 1LL * r * e(t, i) % mod; t = 1; } printf("%d", r); return 0; }

Compilation message (stderr)

FG.cpp: In function 'int main()':
FG.cpp:28:22: 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...