Submission #140198

# Submission time Handle Problem Language Result Execution time Memory
140198 2019-08-02T08:59:55 Z rdd6584 Fully Generate (KRIII5_FG) C++14
2 / 7
500 ms 156816 KB
#include <cstdio>
#include <algorithm>
#include <memory.h>
#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int vec[40000001];

ll mp(ll a, ll b) {
	ll ret = 1;
	while (b) {
		if (b % 2) ret = ret * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}

	return ret;
}

int main() {
	ll n;
	scanf("%lld", &n);

	if (n == 1) return !printf("1");
	if (n == 2) return !printf("2");
	if (n == 3) return !printf("4");

	int now = 3;
	ll cnt = 3;
	ll ans = 4;
	vec[1] = 1, vec[2] = 2, vec[3] = 2;

	while (1) {
		if (vec[now] + cnt >= n) {
			ans = ans * mp(now, n - cnt) % MOD;
			break;
		}

		for (ll i = cnt + 1; i <= vec[now] + cnt && i <= 40000000; i++)
			vec[i] = now;

		ans = ans * mp(now, vec[now]) % MOD;
		cnt += vec[now];
		now++;
	}

	printf("%lld", ans);
}

Compilation message

FG.cpp: In function 'int main()':
FG.cpp:24:7: 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 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 888 KB Output is correct
12 Correct 6 ms 3832 KB Output is correct
13 Correct 5 ms 2808 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 5 ms 3448 KB Output is correct
16 Correct 4 ms 2424 KB Output is correct
17 Correct 3 ms 1528 KB Output is correct
18 Correct 5 ms 3192 KB Output is correct
19 Correct 2 ms 760 KB Output is correct
20 Correct 3 ms 1272 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 4 ms 1784 KB Output is correct
23 Correct 2 ms 892 KB Output is correct
24 Correct 6 ms 3832 KB Output is correct
25 Correct 3 ms 1400 KB Output is correct
26 Correct 2 ms 528 KB Output is correct
27 Correct 5 ms 3448 KB Output is correct
28 Correct 3 ms 1144 KB Output is correct
29 Correct 6 ms 3960 KB Output is correct
30 Correct 3 ms 1784 KB Output is correct
31 Correct 5 ms 2936 KB Output is correct
32 Correct 3 ms 892 KB Output is correct
33 Correct 5 ms 3576 KB Output is correct
34 Correct 3 ms 1528 KB Output is correct
35 Correct 5 ms 3704 KB Output is correct
36 Correct 3 ms 1528 KB Output is correct
37 Correct 2 ms 760 KB Output is correct
38 Correct 4 ms 2296 KB Output is correct
39 Correct 5 ms 3704 KB Output is correct
40 Correct 5 ms 2936 KB Output is correct
41 Correct 3 ms 888 KB Output is correct
42 Correct 5 ms 2936 KB Output is correct
43 Correct 3 ms 888 KB Output is correct
44 Correct 6 ms 3704 KB Output is correct
45 Correct 3 ms 1528 KB Output is correct
46 Correct 6 ms 3704 KB Output is correct
47 Correct 3 ms 1640 KB Output is correct
48 Correct 6 ms 3704 KB Output is correct
49 Correct 4 ms 2296 KB Output is correct
50 Correct 6 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 888 KB Output is correct
12 Correct 6 ms 3832 KB Output is correct
13 Correct 5 ms 2808 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 5 ms 3448 KB Output is correct
16 Correct 4 ms 2424 KB Output is correct
17 Correct 3 ms 1528 KB Output is correct
18 Correct 5 ms 3192 KB Output is correct
19 Correct 2 ms 760 KB Output is correct
20 Correct 3 ms 1272 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 4 ms 1784 KB Output is correct
23 Correct 2 ms 892 KB Output is correct
24 Correct 6 ms 3832 KB Output is correct
25 Correct 3 ms 1400 KB Output is correct
26 Correct 2 ms 528 KB Output is correct
27 Correct 5 ms 3448 KB Output is correct
28 Correct 3 ms 1144 KB Output is correct
29 Correct 6 ms 3960 KB Output is correct
30 Correct 3 ms 1784 KB Output is correct
31 Correct 5 ms 2936 KB Output is correct
32 Correct 3 ms 892 KB Output is correct
33 Correct 5 ms 3576 KB Output is correct
34 Correct 3 ms 1528 KB Output is correct
35 Correct 5 ms 3704 KB Output is correct
36 Correct 3 ms 1528 KB Output is correct
37 Correct 2 ms 760 KB Output is correct
38 Correct 4 ms 2296 KB Output is correct
39 Correct 5 ms 3704 KB Output is correct
40 Correct 5 ms 2936 KB Output is correct
41 Correct 3 ms 888 KB Output is correct
42 Correct 5 ms 2936 KB Output is correct
43 Correct 3 ms 888 KB Output is correct
44 Correct 6 ms 3704 KB Output is correct
45 Correct 3 ms 1528 KB Output is correct
46 Correct 6 ms 3704 KB Output is correct
47 Correct 3 ms 1640 KB Output is correct
48 Correct 6 ms 3704 KB Output is correct
49 Correct 4 ms 2296 KB Output is correct
50 Correct 6 ms 4216 KB Output is correct
51 Execution timed out 1078 ms 156816 KB Time limit exceeded
52 Halted 0 ms 0 KB -