Submission #22331

#TimeUsernameProblemLanguageResultExecution timeMemory
22331↓우리보다잘하는팀 (#40)Fully Generate (KRIII5_FG)C++14
7 / 7
316 ms126116 KiB
#include <cstdio> const int N = 32000000, p = 1000000007; int a[N + 1]; int f(int x, int y) { return y ? y & 1 ? 1ll * f(x, y ^ 1) * x % p : f(1ll * x * x % p, y >> 1) : 1; } int main() { long long n; int i, j, k, m, r; scanf("%lld", &n); a[1] = 1; a[2] = 2; for (i = j = 1; j <= N; i++) for (k = 0; k < a[i] && j <= N; k++) a[j++] = i; for (i = 1; i <= N; i++) { if (a[i] < n) n -= a[i]; else { a[i] = n; n = 0; break; } } r = f(i, a[i]); j = 1; while (--i) { j = 1ll * j * i % p; if (a[i] != a[i - 1]) r = 1ll * r * j % p; } printf("%d", r); }

Compilation message (stderr)

FG.cpp: In function 'int main()':
FG.cpp:13:15: warning: unused variable 'm' [-Wunused-variable]
  int i, j, k, m, r;
               ^
FG.cpp:14: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...