#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;
const int NMX = 40000000;
ll cnt[NMX + 1];
ll sum[NMX + 1];
ll val[NMX + 1];
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;
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, i;
for (i = 3; i <= NMX; i++) {
if (i > sum[p]) p++;
cnt[i] = p;
sum[i] = sum[i - 1] + cnt[i];
if (sum[i] >= N) {
cnt[i] = N - sum[i - 1];
break;
}
}
int mx = i;
for (i = 1; i <= max(cnt[mx - 1], cnt[mx]); i++) val[i] = 1;
for (i = 1; i <= mx; i++) val[cnt[i]] = (val[cnt[i]] * i) % MOD;
ll ans = 1;
for (i = 1;; i++) {
if (!val[i]) break;
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:71: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 |
359 ms |
939520 KB |
Output is correct |
52 |
Correct |
383 ms |
939520 KB |
Output is correct |
53 |
Correct |
379 ms |
939520 KB |
Output is correct |
54 |
Correct |
389 ms |
939520 KB |
Output is correct |
55 |
Correct |
386 ms |
939520 KB |
Output is correct |
56 |
Correct |
376 ms |
939520 KB |
Output is correct |
57 |
Correct |
406 ms |
939520 KB |
Output is correct |
58 |
Correct |
376 ms |
939520 KB |
Output is correct |
59 |
Correct |
379 ms |
939520 KB |
Output is correct |
60 |
Correct |
369 ms |
939520 KB |
Output is correct |
61 |
Correct |
356 ms |
939520 KB |
Output is correct |
62 |
Correct |
369 ms |
939520 KB |
Output is correct |
63 |
Correct |
373 ms |
939520 KB |
Output is correct |
64 |
Correct |
386 ms |
939520 KB |
Output is correct |
65 |
Correct |
379 ms |
939520 KB |
Output is correct |
66 |
Correct |
396 ms |
939520 KB |
Output is correct |
67 |
Correct |
389 ms |
939520 KB |
Output is correct |
68 |
Correct |
399 ms |
939520 KB |
Output is correct |
69 |
Correct |
389 ms |
939520 KB |
Output is correct |
70 |
Correct |
386 ms |
939520 KB |
Output is correct |
71 |
Correct |
243 ms |
939520 KB |
Output is correct |
72 |
Correct |
256 ms |
939520 KB |
Output is correct |
73 |
Correct |
289 ms |
939520 KB |
Output is correct |
74 |
Correct |
266 ms |
939520 KB |
Output is correct |
75 |
Correct |
296 ms |
939520 KB |
Output is correct |
76 |
Correct |
306 ms |
939520 KB |
Output is correct |
77 |
Correct |
313 ms |
939520 KB |
Output is correct |
78 |
Correct |
346 ms |
939520 KB |
Output is correct |
79 |
Correct |
369 ms |
939520 KB |
Output is correct |
80 |
Correct |
369 ms |
939520 KB |
Output is correct |
81 |
Correct |
376 ms |
939520 KB |
Output is correct |
82 |
Correct |
336 ms |
939520 KB |
Output is correct |
83 |
Correct |
396 ms |
939520 KB |
Output is correct |
84 |
Correct |
103 ms |
939520 KB |
Output is correct |
85 |
Correct |
129 ms |
939520 KB |
Output is correct |
86 |
Correct |
136 ms |
939520 KB |
Output is correct |
87 |
Correct |
159 ms |
939520 KB |
Output is correct |
88 |
Correct |
163 ms |
939520 KB |
Output is correct |
89 |
Correct |
203 ms |
939520 KB |
Output is correct |
90 |
Correct |
196 ms |
939520 KB |
Output is correct |
91 |
Correct |
196 ms |
939520 KB |
Output is correct |
92 |
Correct |
236 ms |
939520 KB |
Output is correct |
93 |
Correct |
233 ms |
939520 KB |
Output is correct |
94 |
Correct |
286 ms |
939520 KB |
Output is correct |
95 |
Correct |
243 ms |
939520 KB |
Output is correct |
96 |
Correct |
96 ms |
939520 KB |
Output is correct |
97 |
Correct |
63 ms |
939520 KB |
Output is correct |
98 |
Correct |
83 ms |
939520 KB |
Output is correct |
99 |
Correct |
53 ms |
939520 KB |
Output is correct |
100 |
Correct |
86 ms |
939520 KB |
Output is correct |
101 |
Correct |
49 ms |
939520 KB |
Output is correct |
102 |
Correct |
66 ms |
939520 KB |
Output is correct |
103 |
Correct |
49 ms |
939520 KB |
Output is correct |
104 |
Correct |
79 ms |
939520 KB |
Output is correct |
105 |
Correct |
46 ms |
939520 KB |
Output is correct |
106 |
Correct |
59 ms |
939520 KB |
Output is correct |
107 |
Correct |
33 ms |
939520 KB |
Output is correct |
108 |
Correct |
63 ms |
939520 KB |
Output is correct |
109 |
Correct |
29 ms |
939520 KB |
Output is correct |
110 |
Correct |
59 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 |