#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
const int mmod = 1000000007;
const int m = 32000000;
int G[m+1], H[m+1];
int pw(int a, int b) {
if (b == 0) return 1;
int c= pw(a, b/2);
c = (1LL * c*c) % mmod;
if (b % 2)
c = (1LL * a * c) % mmod;
return c;
}
int main()
{
G[1] = 1;
G[2] = G[3] = 2;
for (int i=3, j=4; ;) {
for (int iter=0; iter<G[i]; iter++) {
G[j++] = i;
if (j == m) break;
}
if (j == m) break;
i ++;
}
/* long long sum = 0;
for (int i=0; i<m/2; i++) sum += G[i];
printf("%lld\n", sum);*/
long long n;
cin >> n;
long long precalc = 1;
int end_i = 0;
if (n >= 336795949707LL) {
n -= 336795949707LL;
end_i = 15999999;
precalc = 496411188;
}
for (int i=end_i+1; n; i++) {
int iter = min((long long)G[i], n);
n -= iter;
if (!H[iter]) H[iter] = i;
else H[iter] = (H[iter] * 1LL * i) % mmod;
}
int res = 1;
int now = 1;
for (int i=m; i>=1; i--) {
if (H[i]) now = (now * 1LL * H[i]) % mmod;
res = (res * 1LL * now) % mmod;
}
cout << (res * precalc) % mmod << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
243 ms |
252020 KB |
Output is correct |
2 |
Correct |
246 ms |
252020 KB |
Output is correct |
3 |
Correct |
243 ms |
252020 KB |
Output is correct |
4 |
Correct |
263 ms |
252020 KB |
Output is correct |
5 |
Correct |
253 ms |
252020 KB |
Output is correct |
6 |
Correct |
233 ms |
252020 KB |
Output is correct |
7 |
Correct |
243 ms |
252020 KB |
Output is correct |
8 |
Correct |
246 ms |
252020 KB |
Output is correct |
9 |
Correct |
269 ms |
252020 KB |
Output is correct |
10 |
Correct |
253 ms |
252020 KB |
Output is correct |
11 |
Correct |
229 ms |
252020 KB |
Output is correct |
12 |
Correct |
259 ms |
252020 KB |
Output is correct |
13 |
Correct |
233 ms |
252020 KB |
Output is correct |
14 |
Correct |
249 ms |
252020 KB |
Output is correct |
15 |
Correct |
256 ms |
252020 KB |
Output is correct |
16 |
Correct |
243 ms |
252020 KB |
Output is correct |
17 |
Correct |
283 ms |
252020 KB |
Output is correct |
18 |
Correct |
246 ms |
252020 KB |
Output is correct |
19 |
Correct |
259 ms |
252020 KB |
Output is correct |
20 |
Correct |
263 ms |
252020 KB |
Output is correct |
21 |
Correct |
256 ms |
252020 KB |
Output is correct |
22 |
Correct |
236 ms |
252020 KB |
Output is correct |
23 |
Correct |
246 ms |
252020 KB |
Output is correct |
24 |
Correct |
246 ms |
252020 KB |
Output is correct |
25 |
Correct |
249 ms |
252020 KB |
Output is correct |
26 |
Correct |
266 ms |
252020 KB |
Output is correct |
27 |
Correct |
246 ms |
252020 KB |
Output is correct |
28 |
Correct |
239 ms |
252020 KB |
Output is correct |
29 |
Correct |
253 ms |
252020 KB |
Output is correct |
30 |
Correct |
259 ms |
252020 KB |
Output is correct |
31 |
Correct |
236 ms |
252020 KB |
Output is correct |
32 |
Correct |
259 ms |
252020 KB |
Output is correct |
33 |
Correct |
243 ms |
252020 KB |
Output is correct |
34 |
Correct |
253 ms |
252020 KB |
Output is correct |
35 |
Correct |
256 ms |
252020 KB |
Output is correct |
36 |
Correct |
256 ms |
252020 KB |
Output is correct |
37 |
Correct |
246 ms |
252020 KB |
Output is correct |
38 |
Correct |
259 ms |
252020 KB |
Output is correct |
39 |
Correct |
236 ms |
252020 KB |
Output is correct |
40 |
Correct |
249 ms |
252020 KB |
Output is correct |
41 |
Correct |
276 ms |
252020 KB |
Output is correct |
42 |
Correct |
249 ms |
252020 KB |
Output is correct |
43 |
Correct |
259 ms |
252020 KB |
Output is correct |
44 |
Correct |
283 ms |
252020 KB |
Output is correct |
45 |
Correct |
256 ms |
252020 KB |
Output is correct |
46 |
Correct |
283 ms |
252020 KB |
Output is correct |
47 |
Correct |
239 ms |
252020 KB |
Output is correct |
48 |
Correct |
263 ms |
252020 KB |
Output is correct |
49 |
Correct |
239 ms |
252020 KB |
Output is correct |
50 |
Correct |
249 ms |
252020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
243 ms |
252020 KB |
Output is correct |
2 |
Correct |
246 ms |
252020 KB |
Output is correct |
3 |
Correct |
243 ms |
252020 KB |
Output is correct |
4 |
Correct |
263 ms |
252020 KB |
Output is correct |
5 |
Correct |
253 ms |
252020 KB |
Output is correct |
6 |
Correct |
233 ms |
252020 KB |
Output is correct |
7 |
Correct |
243 ms |
252020 KB |
Output is correct |
8 |
Correct |
246 ms |
252020 KB |
Output is correct |
9 |
Correct |
269 ms |
252020 KB |
Output is correct |
10 |
Correct |
253 ms |
252020 KB |
Output is correct |
11 |
Correct |
229 ms |
252020 KB |
Output is correct |
12 |
Correct |
259 ms |
252020 KB |
Output is correct |
13 |
Correct |
233 ms |
252020 KB |
Output is correct |
14 |
Correct |
249 ms |
252020 KB |
Output is correct |
15 |
Correct |
256 ms |
252020 KB |
Output is correct |
16 |
Correct |
243 ms |
252020 KB |
Output is correct |
17 |
Correct |
283 ms |
252020 KB |
Output is correct |
18 |
Correct |
246 ms |
252020 KB |
Output is correct |
19 |
Correct |
259 ms |
252020 KB |
Output is correct |
20 |
Correct |
263 ms |
252020 KB |
Output is correct |
21 |
Correct |
256 ms |
252020 KB |
Output is correct |
22 |
Correct |
236 ms |
252020 KB |
Output is correct |
23 |
Correct |
246 ms |
252020 KB |
Output is correct |
24 |
Correct |
246 ms |
252020 KB |
Output is correct |
25 |
Correct |
249 ms |
252020 KB |
Output is correct |
26 |
Correct |
266 ms |
252020 KB |
Output is correct |
27 |
Correct |
246 ms |
252020 KB |
Output is correct |
28 |
Correct |
239 ms |
252020 KB |
Output is correct |
29 |
Correct |
253 ms |
252020 KB |
Output is correct |
30 |
Correct |
259 ms |
252020 KB |
Output is correct |
31 |
Correct |
236 ms |
252020 KB |
Output is correct |
32 |
Correct |
259 ms |
252020 KB |
Output is correct |
33 |
Correct |
243 ms |
252020 KB |
Output is correct |
34 |
Correct |
253 ms |
252020 KB |
Output is correct |
35 |
Correct |
256 ms |
252020 KB |
Output is correct |
36 |
Correct |
256 ms |
252020 KB |
Output is correct |
37 |
Correct |
246 ms |
252020 KB |
Output is correct |
38 |
Correct |
259 ms |
252020 KB |
Output is correct |
39 |
Correct |
236 ms |
252020 KB |
Output is correct |
40 |
Correct |
249 ms |
252020 KB |
Output is correct |
41 |
Correct |
276 ms |
252020 KB |
Output is correct |
42 |
Correct |
249 ms |
252020 KB |
Output is correct |
43 |
Correct |
259 ms |
252020 KB |
Output is correct |
44 |
Correct |
283 ms |
252020 KB |
Output is correct |
45 |
Correct |
256 ms |
252020 KB |
Output is correct |
46 |
Correct |
283 ms |
252020 KB |
Output is correct |
47 |
Correct |
239 ms |
252020 KB |
Output is correct |
48 |
Correct |
263 ms |
252020 KB |
Output is correct |
49 |
Correct |
239 ms |
252020 KB |
Output is correct |
50 |
Correct |
249 ms |
252020 KB |
Output is correct |
51 |
Correct |
409 ms |
252020 KB |
Output is correct |
52 |
Correct |
383 ms |
252020 KB |
Output is correct |
53 |
Correct |
396 ms |
252020 KB |
Output is correct |
54 |
Correct |
383 ms |
252020 KB |
Output is correct |
55 |
Correct |
383 ms |
252020 KB |
Output is correct |
56 |
Correct |
379 ms |
252020 KB |
Output is correct |
57 |
Correct |
383 ms |
252020 KB |
Output is correct |
58 |
Correct |
366 ms |
252020 KB |
Output is correct |
59 |
Correct |
363 ms |
252020 KB |
Output is correct |
60 |
Correct |
383 ms |
252020 KB |
Output is correct |
61 |
Correct |
379 ms |
252020 KB |
Output is correct |
62 |
Correct |
363 ms |
252020 KB |
Output is correct |
63 |
Correct |
363 ms |
252020 KB |
Output is correct |
64 |
Correct |
379 ms |
252020 KB |
Output is correct |
65 |
Correct |
379 ms |
252020 KB |
Output is correct |
66 |
Correct |
366 ms |
252020 KB |
Output is correct |
67 |
Correct |
389 ms |
252020 KB |
Output is correct |
68 |
Correct |
396 ms |
252020 KB |
Output is correct |
69 |
Correct |
376 ms |
252020 KB |
Output is correct |
70 |
Correct |
389 ms |
252020 KB |
Output is correct |
71 |
Correct |
289 ms |
252020 KB |
Output is correct |
72 |
Correct |
296 ms |
252020 KB |
Output is correct |
73 |
Correct |
316 ms |
252020 KB |
Output is correct |
74 |
Correct |
299 ms |
252020 KB |
Output is correct |
75 |
Correct |
329 ms |
252020 KB |
Output is correct |
76 |
Correct |
319 ms |
252020 KB |
Output is correct |
77 |
Correct |
326 ms |
252020 KB |
Output is correct |
78 |
Correct |
349 ms |
252020 KB |
Output is correct |
79 |
Correct |
349 ms |
252020 KB |
Output is correct |
80 |
Correct |
349 ms |
252020 KB |
Output is correct |
81 |
Correct |
359 ms |
252020 KB |
Output is correct |
82 |
Correct |
383 ms |
252020 KB |
Output is correct |
83 |
Correct |
389 ms |
252020 KB |
Output is correct |
84 |
Correct |
326 ms |
252020 KB |
Output is correct |
85 |
Correct |
343 ms |
252020 KB |
Output is correct |
86 |
Correct |
353 ms |
252020 KB |
Output is correct |
87 |
Correct |
363 ms |
252020 KB |
Output is correct |
88 |
Correct |
393 ms |
252020 KB |
Output is correct |
89 |
Correct |
383 ms |
252020 KB |
Output is correct |
90 |
Correct |
249 ms |
252020 KB |
Output is correct |
91 |
Correct |
256 ms |
252020 KB |
Output is correct |
92 |
Correct |
276 ms |
252020 KB |
Output is correct |
93 |
Correct |
293 ms |
252020 KB |
Output is correct |
94 |
Correct |
306 ms |
252020 KB |
Output is correct |
95 |
Correct |
309 ms |
252020 KB |
Output is correct |
96 |
Correct |
316 ms |
252020 KB |
Output is correct |
97 |
Correct |
293 ms |
252020 KB |
Output is correct |
98 |
Correct |
313 ms |
252020 KB |
Output is correct |
99 |
Correct |
299 ms |
252020 KB |
Output is correct |
100 |
Correct |
316 ms |
252020 KB |
Output is correct |
101 |
Correct |
299 ms |
252020 KB |
Output is correct |
102 |
Correct |
299 ms |
252020 KB |
Output is correct |
103 |
Correct |
279 ms |
252020 KB |
Output is correct |
104 |
Correct |
319 ms |
252020 KB |
Output is correct |
105 |
Correct |
263 ms |
252020 KB |
Output is correct |
106 |
Correct |
289 ms |
252020 KB |
Output is correct |
107 |
Correct |
273 ms |
252020 KB |
Output is correct |
108 |
Correct |
286 ms |
252020 KB |
Output is correct |
109 |
Correct |
276 ms |
252020 KB |
Output is correct |
110 |
Correct |
309 ms |
252020 KB |
Output is correct |
111 |
Correct |
256 ms |
252020 KB |
Output is correct |
112 |
Correct |
263 ms |
252020 KB |
Output is correct |
113 |
Correct |
246 ms |
252020 KB |
Output is correct |
114 |
Correct |
263 ms |
252020 KB |
Output is correct |
115 |
Correct |
276 ms |
252020 KB |
Output is correct |
116 |
Correct |
273 ms |
252020 KB |
Output is correct |
117 |
Correct |
256 ms |
252020 KB |
Output is correct |
118 |
Correct |
273 ms |
252020 KB |
Output is correct |
119 |
Correct |
239 ms |
252020 KB |
Output is correct |
120 |
Correct |
263 ms |
252020 KB |
Output is correct |