#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int PMAX = 4e7;
const int QMAX = 70000;
int dp[PMAX + 1]; // dp[i]: i�� ������ �� �� �����ϴ°�?
ll psum[PMAX + 1];
vector<int> deg[QMAX + 1];
ll fastpow(ll x, ll y) {
if (y == 0) return 1;
if (y % 2) return x*fastpow(x, y - 1) % MOD;
ll h = fastpow(x, y / 2);
return h*h%MOD;
}
int main() {
ll N; scanf("%lld", &N);
dp[1] = psum[1] = 1;
dp[2] = 2;
psum[2] = 3;
int j = 2;
for (int i = 3; i <= PMAX; i++) {
// find min(j) s.t. psum[j] >= i
while (psum[j] < i) j++;
// now psum[j] >= i
dp[i] = j;
psum[i] = psum[i - 1] + j;
}
int maxint = lower_bound(psum + 1, psum + 1 + PMAX, N) - psum;
int maxdp = -1;
for (int i = 2; i < maxint; i++) {
deg[dp[i]].push_back(i);
maxdp = max(maxdp, dp[i]);
}
ll ans = 1;
for (int i = 2; i <= maxdp; i++) {
ll cur = 1;
for (int x : deg[i]) cur = cur*x%MOD;
ans = ans*fastpow(cur, i) % MOD;
}
ll last = N - psum[maxint - 1];
ans = ans*fastpow(maxint, last) % MOD;
printf("%lld", ans);
}
Compilation message
FG.cpp: In function 'int main()':
FG.cpp:23:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
ll N; scanf("%lld", &N);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
471560 KB |
Output is correct |
2 |
Correct |
69 ms |
471560 KB |
Output is correct |
3 |
Correct |
83 ms |
471560 KB |
Output is correct |
4 |
Correct |
89 ms |
471560 KB |
Output is correct |
5 |
Correct |
59 ms |
471560 KB |
Output is correct |
6 |
Correct |
59 ms |
471560 KB |
Output is correct |
7 |
Correct |
69 ms |
471560 KB |
Output is correct |
8 |
Correct |
79 ms |
471560 KB |
Output is correct |
9 |
Correct |
79 ms |
471560 KB |
Output is correct |
10 |
Correct |
76 ms |
471560 KB |
Output is correct |
11 |
Correct |
93 ms |
471560 KB |
Output is correct |
12 |
Correct |
79 ms |
471560 KB |
Output is correct |
13 |
Correct |
86 ms |
471560 KB |
Output is correct |
14 |
Correct |
96 ms |
471560 KB |
Output is correct |
15 |
Correct |
126 ms |
471560 KB |
Output is correct |
16 |
Correct |
69 ms |
471560 KB |
Output is correct |
17 |
Correct |
69 ms |
471560 KB |
Output is correct |
18 |
Correct |
66 ms |
471560 KB |
Output is correct |
19 |
Correct |
76 ms |
471560 KB |
Output is correct |
20 |
Correct |
69 ms |
471560 KB |
Output is correct |
21 |
Correct |
123 ms |
471560 KB |
Output is correct |
22 |
Correct |
96 ms |
471560 KB |
Output is correct |
23 |
Correct |
73 ms |
471560 KB |
Output is correct |
24 |
Correct |
83 ms |
471560 KB |
Output is correct |
25 |
Correct |
46 ms |
471560 KB |
Output is correct |
26 |
Correct |
106 ms |
471560 KB |
Output is correct |
27 |
Correct |
76 ms |
471560 KB |
Output is correct |
28 |
Correct |
79 ms |
471560 KB |
Output is correct |
29 |
Correct |
69 ms |
471560 KB |
Output is correct |
30 |
Correct |
76 ms |
471560 KB |
Output is correct |
31 |
Correct |
66 ms |
471560 KB |
Output is correct |
32 |
Correct |
49 ms |
471560 KB |
Output is correct |
33 |
Correct |
73 ms |
471560 KB |
Output is correct |
34 |
Correct |
69 ms |
471560 KB |
Output is correct |
35 |
Correct |
109 ms |
471560 KB |
Output is correct |
36 |
Correct |
99 ms |
471560 KB |
Output is correct |
37 |
Correct |
73 ms |
471560 KB |
Output is correct |
38 |
Correct |
96 ms |
471560 KB |
Output is correct |
39 |
Correct |
79 ms |
471560 KB |
Output is correct |
40 |
Correct |
83 ms |
471560 KB |
Output is correct |
41 |
Correct |
93 ms |
471560 KB |
Output is correct |
42 |
Correct |
76 ms |
471560 KB |
Output is correct |
43 |
Correct |
73 ms |
471560 KB |
Output is correct |
44 |
Correct |
79 ms |
471560 KB |
Output is correct |
45 |
Correct |
96 ms |
471560 KB |
Output is correct |
46 |
Correct |
76 ms |
471560 KB |
Output is correct |
47 |
Correct |
96 ms |
471560 KB |
Output is correct |
48 |
Correct |
76 ms |
471560 KB |
Output is correct |
49 |
Correct |
56 ms |
471560 KB |
Output is correct |
50 |
Correct |
66 ms |
471560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
471560 KB |
Output is correct |
2 |
Correct |
69 ms |
471560 KB |
Output is correct |
3 |
Correct |
83 ms |
471560 KB |
Output is correct |
4 |
Correct |
89 ms |
471560 KB |
Output is correct |
5 |
Correct |
59 ms |
471560 KB |
Output is correct |
6 |
Correct |
59 ms |
471560 KB |
Output is correct |
7 |
Correct |
69 ms |
471560 KB |
Output is correct |
8 |
Correct |
79 ms |
471560 KB |
Output is correct |
9 |
Correct |
79 ms |
471560 KB |
Output is correct |
10 |
Correct |
76 ms |
471560 KB |
Output is correct |
11 |
Correct |
93 ms |
471560 KB |
Output is correct |
12 |
Correct |
79 ms |
471560 KB |
Output is correct |
13 |
Correct |
86 ms |
471560 KB |
Output is correct |
14 |
Correct |
96 ms |
471560 KB |
Output is correct |
15 |
Correct |
126 ms |
471560 KB |
Output is correct |
16 |
Correct |
69 ms |
471560 KB |
Output is correct |
17 |
Correct |
69 ms |
471560 KB |
Output is correct |
18 |
Correct |
66 ms |
471560 KB |
Output is correct |
19 |
Correct |
76 ms |
471560 KB |
Output is correct |
20 |
Correct |
69 ms |
471560 KB |
Output is correct |
21 |
Correct |
123 ms |
471560 KB |
Output is correct |
22 |
Correct |
96 ms |
471560 KB |
Output is correct |
23 |
Correct |
73 ms |
471560 KB |
Output is correct |
24 |
Correct |
83 ms |
471560 KB |
Output is correct |
25 |
Correct |
46 ms |
471560 KB |
Output is correct |
26 |
Correct |
106 ms |
471560 KB |
Output is correct |
27 |
Correct |
76 ms |
471560 KB |
Output is correct |
28 |
Correct |
79 ms |
471560 KB |
Output is correct |
29 |
Correct |
69 ms |
471560 KB |
Output is correct |
30 |
Correct |
76 ms |
471560 KB |
Output is correct |
31 |
Correct |
66 ms |
471560 KB |
Output is correct |
32 |
Correct |
49 ms |
471560 KB |
Output is correct |
33 |
Correct |
73 ms |
471560 KB |
Output is correct |
34 |
Correct |
69 ms |
471560 KB |
Output is correct |
35 |
Correct |
109 ms |
471560 KB |
Output is correct |
36 |
Correct |
99 ms |
471560 KB |
Output is correct |
37 |
Correct |
73 ms |
471560 KB |
Output is correct |
38 |
Correct |
96 ms |
471560 KB |
Output is correct |
39 |
Correct |
79 ms |
471560 KB |
Output is correct |
40 |
Correct |
83 ms |
471560 KB |
Output is correct |
41 |
Correct |
93 ms |
471560 KB |
Output is correct |
42 |
Correct |
76 ms |
471560 KB |
Output is correct |
43 |
Correct |
73 ms |
471560 KB |
Output is correct |
44 |
Correct |
79 ms |
471560 KB |
Output is correct |
45 |
Correct |
96 ms |
471560 KB |
Output is correct |
46 |
Correct |
76 ms |
471560 KB |
Output is correct |
47 |
Correct |
96 ms |
471560 KB |
Output is correct |
48 |
Correct |
76 ms |
471560 KB |
Output is correct |
49 |
Correct |
56 ms |
471560 KB |
Output is correct |
50 |
Correct |
66 ms |
471560 KB |
Output is correct |
51 |
Correct |
453 ms |
635800 KB |
Output is correct |
52 |
Correct |
439 ms |
635800 KB |
Output is correct |
53 |
Correct |
446 ms |
635800 KB |
Output is correct |
54 |
Correct |
453 ms |
635800 KB |
Output is correct |
55 |
Correct |
446 ms |
635800 KB |
Output is correct |
56 |
Correct |
449 ms |
635800 KB |
Output is correct |
57 |
Correct |
456 ms |
635800 KB |
Output is correct |
58 |
Correct |
443 ms |
635800 KB |
Output is correct |
59 |
Correct |
456 ms |
635800 KB |
Output is correct |
60 |
Correct |
416 ms |
635800 KB |
Output is correct |
61 |
Correct |
466 ms |
635800 KB |
Output is correct |
62 |
Correct |
466 ms |
635800 KB |
Output is correct |
63 |
Correct |
469 ms |
635800 KB |
Output is correct |
64 |
Correct |
493 ms |
635800 KB |
Output is correct |
65 |
Correct |
459 ms |
635800 KB |
Output is correct |
66 |
Correct |
453 ms |
635800 KB |
Output is correct |
67 |
Execution timed out |
500 ms |
635800 KB |
Execution timed out |
68 |
Halted |
0 ms |
0 KB |
- |