#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1034567890123456789ll;
const db PI = acos(-1);
const db ERR = 1E-11;
ll cnt[40000000];
ll sum[40000000];
ll val[40000000];
ll mypow(ll a, ll b) {
ll rv = 1;
while (b) {
if (b % 2) rv = (rv * a) % MOD;
a = (a*a) % MOD;
b /= 2;
}
return rv;
}
int main() {
cnt[1] = 1, cnt[2] = 2;
sum[1] = 1, sum[2] = 3;
ll N, i;
scanf("%lld", &N);
if (N == 1) return !printf("1\n");
if (N == 2) return !printf("2\n");
if (N == 3) return !printf("4\n");
int p = 2;
for (i = 3;; i++) {
if (sum[p] < i) p++;
cnt[i] = p;
sum[i] = sum[i - 1] + cnt[i];
if (sum[i] > N) {
cnt[i] = N - sum[i - 1];
break;
}
}
int x = i;
for (i = 1; i <= max(cnt[x - 1], cnt[x]); i++) val[i] = 1;
for (i = 1; i <= x; i++) val[cnt[i]] = (val[cnt[i]] * i) % MOD;
ll ans = 1;
for (i = 1; i <= max(cnt[x - 1], cnt[x]); i++) ans = (ans * mypow(val[i], i)) % MOD;
return !printf("%lld\n", ans);
}
Compilation message
FG.cpp:22:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
^
FG.cpp:23:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/STACK:336777216")
^
FG.cpp: In function 'int main()':
FG.cpp:70:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &N);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
939520 KB |
Output is correct |
2 |
Correct |
0 ms |
939520 KB |
Output is correct |
3 |
Correct |
0 ms |
939520 KB |
Output is correct |
4 |
Correct |
0 ms |
939520 KB |
Output is correct |
5 |
Correct |
0 ms |
939520 KB |
Output is correct |
6 |
Correct |
0 ms |
939520 KB |
Output is correct |
7 |
Correct |
0 ms |
939520 KB |
Output is correct |
8 |
Correct |
0 ms |
939520 KB |
Output is correct |
9 |
Correct |
0 ms |
939520 KB |
Output is correct |
10 |
Correct |
0 ms |
939520 KB |
Output is correct |
11 |
Correct |
0 ms |
939520 KB |
Output is correct |
12 |
Correct |
0 ms |
939520 KB |
Output is correct |
13 |
Correct |
0 ms |
939520 KB |
Output is correct |
14 |
Correct |
0 ms |
939520 KB |
Output is correct |
15 |
Correct |
0 ms |
939520 KB |
Output is correct |
16 |
Correct |
0 ms |
939520 KB |
Output is correct |
17 |
Correct |
0 ms |
939520 KB |
Output is correct |
18 |
Correct |
0 ms |
939520 KB |
Output is correct |
19 |
Correct |
0 ms |
939520 KB |
Output is correct |
20 |
Correct |
0 ms |
939520 KB |
Output is correct |
21 |
Correct |
0 ms |
939520 KB |
Output is correct |
22 |
Correct |
0 ms |
939520 KB |
Output is correct |
23 |
Correct |
0 ms |
939520 KB |
Output is correct |
24 |
Correct |
0 ms |
939520 KB |
Output is correct |
25 |
Correct |
0 ms |
939520 KB |
Output is correct |
26 |
Correct |
0 ms |
939520 KB |
Output is correct |
27 |
Correct |
0 ms |
939520 KB |
Output is correct |
28 |
Correct |
0 ms |
939520 KB |
Output is correct |
29 |
Correct |
0 ms |
939520 KB |
Output is correct |
30 |
Correct |
0 ms |
939520 KB |
Output is correct |
31 |
Correct |
0 ms |
939520 KB |
Output is correct |
32 |
Correct |
0 ms |
939520 KB |
Output is correct |
33 |
Correct |
0 ms |
939520 KB |
Output is correct |
34 |
Correct |
0 ms |
939520 KB |
Output is correct |
35 |
Correct |
0 ms |
939520 KB |
Output is correct |
36 |
Correct |
0 ms |
939520 KB |
Output is correct |
37 |
Correct |
0 ms |
939520 KB |
Output is correct |
38 |
Correct |
0 ms |
939520 KB |
Output is correct |
39 |
Correct |
0 ms |
939520 KB |
Output is correct |
40 |
Correct |
0 ms |
939520 KB |
Output is correct |
41 |
Correct |
0 ms |
939520 KB |
Output is correct |
42 |
Correct |
0 ms |
939520 KB |
Output is correct |
43 |
Correct |
0 ms |
939520 KB |
Output is correct |
44 |
Correct |
0 ms |
939520 KB |
Output is correct |
45 |
Correct |
0 ms |
939520 KB |
Output is correct |
46 |
Correct |
0 ms |
939520 KB |
Output is correct |
47 |
Correct |
0 ms |
939520 KB |
Output is correct |
48 |
Correct |
0 ms |
939520 KB |
Output is correct |
49 |
Correct |
0 ms |
939520 KB |
Output is correct |
50 |
Correct |
0 ms |
939520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
939520 KB |
Output is correct |
2 |
Correct |
0 ms |
939520 KB |
Output is correct |
3 |
Correct |
0 ms |
939520 KB |
Output is correct |
4 |
Correct |
0 ms |
939520 KB |
Output is correct |
5 |
Correct |
0 ms |
939520 KB |
Output is correct |
6 |
Correct |
0 ms |
939520 KB |
Output is correct |
7 |
Correct |
0 ms |
939520 KB |
Output is correct |
8 |
Correct |
0 ms |
939520 KB |
Output is correct |
9 |
Correct |
0 ms |
939520 KB |
Output is correct |
10 |
Correct |
0 ms |
939520 KB |
Output is correct |
11 |
Correct |
0 ms |
939520 KB |
Output is correct |
12 |
Correct |
0 ms |
939520 KB |
Output is correct |
13 |
Correct |
0 ms |
939520 KB |
Output is correct |
14 |
Correct |
0 ms |
939520 KB |
Output is correct |
15 |
Correct |
0 ms |
939520 KB |
Output is correct |
16 |
Correct |
0 ms |
939520 KB |
Output is correct |
17 |
Correct |
0 ms |
939520 KB |
Output is correct |
18 |
Correct |
0 ms |
939520 KB |
Output is correct |
19 |
Correct |
0 ms |
939520 KB |
Output is correct |
20 |
Correct |
0 ms |
939520 KB |
Output is correct |
21 |
Correct |
0 ms |
939520 KB |
Output is correct |
22 |
Correct |
0 ms |
939520 KB |
Output is correct |
23 |
Correct |
0 ms |
939520 KB |
Output is correct |
24 |
Correct |
0 ms |
939520 KB |
Output is correct |
25 |
Correct |
0 ms |
939520 KB |
Output is correct |
26 |
Correct |
0 ms |
939520 KB |
Output is correct |
27 |
Correct |
0 ms |
939520 KB |
Output is correct |
28 |
Correct |
0 ms |
939520 KB |
Output is correct |
29 |
Correct |
0 ms |
939520 KB |
Output is correct |
30 |
Correct |
0 ms |
939520 KB |
Output is correct |
31 |
Correct |
0 ms |
939520 KB |
Output is correct |
32 |
Correct |
0 ms |
939520 KB |
Output is correct |
33 |
Correct |
0 ms |
939520 KB |
Output is correct |
34 |
Correct |
0 ms |
939520 KB |
Output is correct |
35 |
Correct |
0 ms |
939520 KB |
Output is correct |
36 |
Correct |
0 ms |
939520 KB |
Output is correct |
37 |
Correct |
0 ms |
939520 KB |
Output is correct |
38 |
Correct |
0 ms |
939520 KB |
Output is correct |
39 |
Correct |
0 ms |
939520 KB |
Output is correct |
40 |
Correct |
0 ms |
939520 KB |
Output is correct |
41 |
Correct |
0 ms |
939520 KB |
Output is correct |
42 |
Correct |
0 ms |
939520 KB |
Output is correct |
43 |
Correct |
0 ms |
939520 KB |
Output is correct |
44 |
Correct |
0 ms |
939520 KB |
Output is correct |
45 |
Correct |
0 ms |
939520 KB |
Output is correct |
46 |
Correct |
0 ms |
939520 KB |
Output is correct |
47 |
Correct |
0 ms |
939520 KB |
Output is correct |
48 |
Correct |
0 ms |
939520 KB |
Output is correct |
49 |
Correct |
0 ms |
939520 KB |
Output is correct |
50 |
Correct |
0 ms |
939520 KB |
Output is correct |
51 |
Correct |
366 ms |
939520 KB |
Output is correct |
52 |
Correct |
369 ms |
939520 KB |
Output is correct |
53 |
Correct |
396 ms |
939520 KB |
Output is correct |
54 |
Correct |
383 ms |
939520 KB |
Output is correct |
55 |
Correct |
389 ms |
939520 KB |
Output is correct |
56 |
Correct |
393 ms |
939520 KB |
Output is correct |
57 |
Correct |
386 ms |
939520 KB |
Output is correct |
58 |
Correct |
393 ms |
939520 KB |
Output is correct |
59 |
Correct |
389 ms |
939520 KB |
Output is correct |
60 |
Correct |
389 ms |
939520 KB |
Output is correct |
61 |
Correct |
383 ms |
939520 KB |
Output is correct |
62 |
Correct |
369 ms |
939520 KB |
Output is correct |
63 |
Correct |
383 ms |
939520 KB |
Output is correct |
64 |
Correct |
363 ms |
939520 KB |
Output is correct |
65 |
Correct |
419 ms |
939520 KB |
Output is correct |
66 |
Correct |
383 ms |
939520 KB |
Output is correct |
67 |
Correct |
369 ms |
939520 KB |
Output is correct |
68 |
Correct |
376 ms |
939520 KB |
Output is correct |
69 |
Correct |
389 ms |
939520 KB |
Output is correct |
70 |
Correct |
359 ms |
939520 KB |
Output is correct |
71 |
Correct |
249 ms |
939520 KB |
Output is correct |
72 |
Correct |
253 ms |
939520 KB |
Output is correct |
73 |
Correct |
283 ms |
939520 KB |
Output is correct |
74 |
Correct |
293 ms |
939520 KB |
Output is correct |
75 |
Correct |
303 ms |
939520 KB |
Output is correct |
76 |
Correct |
303 ms |
939520 KB |
Output is correct |
77 |
Correct |
323 ms |
939520 KB |
Output is correct |
78 |
Correct |
326 ms |
939520 KB |
Output is correct |
79 |
Correct |
329 ms |
939520 KB |
Output is correct |
80 |
Correct |
336 ms |
939520 KB |
Output is correct |
81 |
Correct |
356 ms |
939520 KB |
Output is correct |
82 |
Correct |
393 ms |
939520 KB |
Output is correct |
83 |
Correct |
426 ms |
939520 KB |
Output is correct |
84 |
Correct |
93 ms |
939520 KB |
Output is correct |
85 |
Correct |
133 ms |
939520 KB |
Output is correct |
86 |
Correct |
153 ms |
939520 KB |
Output is correct |
87 |
Correct |
173 ms |
939520 KB |
Output is correct |
88 |
Correct |
183 ms |
939520 KB |
Output is correct |
89 |
Correct |
203 ms |
939520 KB |
Output is correct |
90 |
Correct |
239 ms |
939520 KB |
Output is correct |
91 |
Correct |
213 ms |
939520 KB |
Output is correct |
92 |
Correct |
213 ms |
939520 KB |
Output is correct |
93 |
Correct |
269 ms |
939520 KB |
Output is correct |
94 |
Correct |
263 ms |
939520 KB |
Output is correct |
95 |
Correct |
303 ms |
939520 KB |
Output is correct |
96 |
Correct |
83 ms |
939520 KB |
Output is correct |
97 |
Correct |
46 ms |
939520 KB |
Output is correct |
98 |
Correct |
73 ms |
939520 KB |
Output is correct |
99 |
Correct |
69 ms |
939520 KB |
Output is correct |
100 |
Correct |
83 ms |
939520 KB |
Output is correct |
101 |
Correct |
43 ms |
939520 KB |
Output is correct |
102 |
Correct |
86 ms |
939520 KB |
Output is correct |
103 |
Correct |
49 ms |
939520 KB |
Output is correct |
104 |
Correct |
83 ms |
939520 KB |
Output is correct |
105 |
Correct |
36 ms |
939520 KB |
Output is correct |
106 |
Correct |
66 ms |
939520 KB |
Output is correct |
107 |
Correct |
26 ms |
939520 KB |
Output is correct |
108 |
Correct |
69 ms |
939520 KB |
Output is correct |
109 |
Correct |
29 ms |
939520 KB |
Output is correct |
110 |
Correct |
63 ms |
939520 KB |
Output is correct |
111 |
Correct |
0 ms |
939520 KB |
Output is correct |
112 |
Correct |
0 ms |
939520 KB |
Output is correct |
113 |
Correct |
0 ms |
939520 KB |
Output is correct |
114 |
Correct |
0 ms |
939520 KB |
Output is correct |
115 |
Correct |
0 ms |
939520 KB |
Output is correct |
116 |
Correct |
0 ms |
939520 KB |
Output is correct |
117 |
Correct |
0 ms |
939520 KB |
Output is correct |
118 |
Correct |
0 ms |
939520 KB |
Output is correct |
119 |
Correct |
0 ms |
939520 KB |
Output is correct |
120 |
Correct |
0 ms |
939520 KB |
Output is correct |