#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<list>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<cmath>
#include<string>
#define sd(a) scanf("%d", &a);
#define sld(a) scanf("%lld", &a);
#define MOD 1000000007
using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;
int xx[4] = { 0, 0, -1, 1 };
int yy[4] = { -1, 1, 0, 0 };
lli N;
lli cal(lli A, lli B) {
lli ret = 1;
while (B != 0) {
if (B % 2 == 0) {
A *= A;
A %= MOD;
B /= 2;
}
else {
ret *= A;
ret %= MOD;
B--;
}
}
return ret;
}
vector<lli> ve;
int main(void) {
sld(N);
ve.push_back(0);
ve.push_back(1);
ve.push_back(2);
ve.push_back(2);
if (N == 1) {
printf("1");
return 0;
}
else if (N == 2) {
printf("2");
return 0;
}
else if (N == 3) {
printf("4");
return 0;
}
else if (N == 4) {
printf("12");
return 0;
}
else if (N == 5) {
printf("36");
return 0;
}
lli ind = 3;
lli cur = ve[ind];
lli hap = 5;
lli ans = 36;
for (int i = 4; ; i++) {
if (cur == 0) {
ind++;
cur = ve[ind];
}
if (hap + ind >= N) {
break;
}
ans *= cal(ve.size(), ind);
ans %= MOD;
ve.push_back(ind);
hap += ind;
cur--;
}
ans *= cal(ve.size(), N - hap);
ans %= MOD;
printf("%lld", ans);
return 0;
}
Compilation message
FG.cpp: In function 'int main()':
FG.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
#define sld(a) scanf("%lld", &a);
^
FG.cpp:49:2: note: in expansion of macro 'sld'
sld(N);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1172 KB |
Output is correct |
2 |
Correct |
0 ms |
1172 KB |
Output is correct |
3 |
Correct |
0 ms |
1172 KB |
Output is correct |
4 |
Correct |
0 ms |
1172 KB |
Output is correct |
5 |
Correct |
0 ms |
1172 KB |
Output is correct |
6 |
Correct |
0 ms |
1172 KB |
Output is correct |
7 |
Correct |
0 ms |
1172 KB |
Output is correct |
8 |
Correct |
0 ms |
1172 KB |
Output is correct |
9 |
Correct |
0 ms |
1172 KB |
Output is correct |
10 |
Correct |
0 ms |
1172 KB |
Output is correct |
11 |
Correct |
0 ms |
1172 KB |
Output is correct |
12 |
Correct |
0 ms |
1312 KB |
Output is correct |
13 |
Correct |
0 ms |
1312 KB |
Output is correct |
14 |
Correct |
0 ms |
1172 KB |
Output is correct |
15 |
Correct |
0 ms |
1312 KB |
Output is correct |
16 |
Correct |
0 ms |
1312 KB |
Output is correct |
17 |
Correct |
0 ms |
1312 KB |
Output is correct |
18 |
Correct |
0 ms |
1312 KB |
Output is correct |
19 |
Correct |
0 ms |
1172 KB |
Output is correct |
20 |
Correct |
0 ms |
1312 KB |
Output is correct |
21 |
Correct |
0 ms |
1312 KB |
Output is correct |
22 |
Correct |
0 ms |
1312 KB |
Output is correct |
23 |
Correct |
0 ms |
1172 KB |
Output is correct |
24 |
Correct |
0 ms |
1312 KB |
Output is correct |
25 |
Correct |
0 ms |
1312 KB |
Output is correct |
26 |
Correct |
0 ms |
1172 KB |
Output is correct |
27 |
Correct |
0 ms |
1312 KB |
Output is correct |
28 |
Correct |
0 ms |
1312 KB |
Output is correct |
29 |
Correct |
0 ms |
1312 KB |
Output is correct |
30 |
Correct |
0 ms |
1312 KB |
Output is correct |
31 |
Correct |
0 ms |
1312 KB |
Output is correct |
32 |
Correct |
0 ms |
1172 KB |
Output is correct |
33 |
Correct |
0 ms |
1312 KB |
Output is correct |
34 |
Correct |
0 ms |
1312 KB |
Output is correct |
35 |
Correct |
0 ms |
1312 KB |
Output is correct |
36 |
Correct |
0 ms |
1312 KB |
Output is correct |
37 |
Correct |
0 ms |
1172 KB |
Output is correct |
38 |
Correct |
0 ms |
1312 KB |
Output is correct |
39 |
Correct |
0 ms |
1312 KB |
Output is correct |
40 |
Correct |
0 ms |
1312 KB |
Output is correct |
41 |
Correct |
0 ms |
1172 KB |
Output is correct |
42 |
Correct |
0 ms |
1312 KB |
Output is correct |
43 |
Correct |
0 ms |
1172 KB |
Output is correct |
44 |
Correct |
0 ms |
1312 KB |
Output is correct |
45 |
Correct |
0 ms |
1312 KB |
Output is correct |
46 |
Correct |
0 ms |
1312 KB |
Output is correct |
47 |
Correct |
0 ms |
1312 KB |
Output is correct |
48 |
Correct |
0 ms |
1312 KB |
Output is correct |
49 |
Correct |
0 ms |
1312 KB |
Output is correct |
50 |
Correct |
0 ms |
1312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1172 KB |
Output is correct |
2 |
Correct |
0 ms |
1172 KB |
Output is correct |
3 |
Correct |
0 ms |
1172 KB |
Output is correct |
4 |
Correct |
0 ms |
1172 KB |
Output is correct |
5 |
Correct |
0 ms |
1172 KB |
Output is correct |
6 |
Correct |
0 ms |
1172 KB |
Output is correct |
7 |
Correct |
0 ms |
1172 KB |
Output is correct |
8 |
Correct |
0 ms |
1172 KB |
Output is correct |
9 |
Correct |
0 ms |
1172 KB |
Output is correct |
10 |
Correct |
0 ms |
1172 KB |
Output is correct |
11 |
Correct |
0 ms |
1172 KB |
Output is correct |
12 |
Correct |
0 ms |
1312 KB |
Output is correct |
13 |
Correct |
0 ms |
1312 KB |
Output is correct |
14 |
Correct |
0 ms |
1172 KB |
Output is correct |
15 |
Correct |
0 ms |
1312 KB |
Output is correct |
16 |
Correct |
0 ms |
1312 KB |
Output is correct |
17 |
Correct |
0 ms |
1312 KB |
Output is correct |
18 |
Correct |
0 ms |
1312 KB |
Output is correct |
19 |
Correct |
0 ms |
1172 KB |
Output is correct |
20 |
Correct |
0 ms |
1312 KB |
Output is correct |
21 |
Correct |
0 ms |
1312 KB |
Output is correct |
22 |
Correct |
0 ms |
1312 KB |
Output is correct |
23 |
Correct |
0 ms |
1172 KB |
Output is correct |
24 |
Correct |
0 ms |
1312 KB |
Output is correct |
25 |
Correct |
0 ms |
1312 KB |
Output is correct |
26 |
Correct |
0 ms |
1172 KB |
Output is correct |
27 |
Correct |
0 ms |
1312 KB |
Output is correct |
28 |
Correct |
0 ms |
1312 KB |
Output is correct |
29 |
Correct |
0 ms |
1312 KB |
Output is correct |
30 |
Correct |
0 ms |
1312 KB |
Output is correct |
31 |
Correct |
0 ms |
1312 KB |
Output is correct |
32 |
Correct |
0 ms |
1172 KB |
Output is correct |
33 |
Correct |
0 ms |
1312 KB |
Output is correct |
34 |
Correct |
0 ms |
1312 KB |
Output is correct |
35 |
Correct |
0 ms |
1312 KB |
Output is correct |
36 |
Correct |
0 ms |
1312 KB |
Output is correct |
37 |
Correct |
0 ms |
1172 KB |
Output is correct |
38 |
Correct |
0 ms |
1312 KB |
Output is correct |
39 |
Correct |
0 ms |
1312 KB |
Output is correct |
40 |
Correct |
0 ms |
1312 KB |
Output is correct |
41 |
Correct |
0 ms |
1172 KB |
Output is correct |
42 |
Correct |
0 ms |
1312 KB |
Output is correct |
43 |
Correct |
0 ms |
1172 KB |
Output is correct |
44 |
Correct |
0 ms |
1312 KB |
Output is correct |
45 |
Correct |
0 ms |
1312 KB |
Output is correct |
46 |
Correct |
0 ms |
1312 KB |
Output is correct |
47 |
Correct |
0 ms |
1312 KB |
Output is correct |
48 |
Correct |
0 ms |
1312 KB |
Output is correct |
49 |
Correct |
0 ms |
1312 KB |
Output is correct |
50 |
Correct |
0 ms |
1312 KB |
Output is correct |
51 |
Execution timed out |
500 ms |
197864 KB |
Execution timed out |
52 |
Halted |
0 ms |
0 KB |
- |