Submission #267076

# Submission time Handle Problem Language Result Execution time Memory
267076 2020-08-15T19:08:33 Z Kenzo_1114 Toys (CEOI18_toy) C++17
39 / 100
1042 ms 640 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXV = 40;

int n, s[MAXV], sz;
vector<int> v;
set<int> ans;
set<int> :: iterator it;
map<int, bool> marc;

void BKT(int num, int sum)
{	
	if(num == 1){	ans.insert(num + sum - 1); return;	}

	for(int i = 0; i < v.size(); i++)
		if(num % v[i] == 0)	BKT(num / v[i], sum + v[i] - 1);
}

int main ()
{
	scanf("%d", &n);
	int N = n;

	for(long long int i = 2; i * i <= n; i++)
	{
		if(n % i == 0)	v.push_back(i), marc[i] = true;
		while(n % i == 0)	n /= i;
	}
	if(n > 1)	v.push_back(n), marc[n] = true;

	for(int k = 0; k <= 30; k++)
	{
		vector<int> aux;
		for(int i = 0; i < v.size(); i++)
		{
			for(int j = 0; j < v.size(); j++)
			{
				int cur = v[i] * v[j];
				if(!marc[cur] && N % cur == 0)
					marc[cur] = true, aux.push_back(cur);
			}
		}
		for(int i = 0; i < aux.size(); i++)	v.push_back(aux[i]);
	}

	sort(v.begin(), v.end());

	BKT(N, 0);

	printf("%d\n", (int) ans.size());
	for(it = ans.begin(); it != ans.end(); it++) printf("%d ", (*it));
	printf("\n");
}

Compilation message

toy.cpp: In function 'void BKT(int, int)':
toy.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0; i < v.size(); i++)
      |                 ~~^~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
toy.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for(int j = 0; j < v.size(); j++)
      |                   ~~^~~~~~~~~~
toy.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i = 0; i < aux.size(); i++) v.push_back(aux[i]);
      |                  ~~^~~~~~~~~~~~
toy.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 15 ms 384 KB Output is correct
27 Correct 13 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 30 ms 388 KB Output is correct
32 Correct 17 ms 384 KB Output is correct
33 Correct 13 ms 384 KB Output is correct
34 Correct 1 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 1 ms 256 KB Output is correct
40 Correct 6 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 1 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 ms 256 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 15 ms 384 KB Output is correct
27 Correct 13 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 30 ms 388 KB Output is correct
32 Correct 17 ms 384 KB Output is correct
33 Correct 13 ms 384 KB Output is correct
34 Correct 1 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 1 ms 256 KB Output is correct
40 Correct 6 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 1 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 ms 256 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 263 ms 444 KB Output is correct
51 Correct 204 ms 384 KB Output is correct
52 Correct 308 ms 384 KB Output is correct
53 Correct 244 ms 504 KB Output is correct
54 Correct 53 ms 512 KB Output is correct
55 Correct 1037 ms 556 KB Output is correct
56 Correct 1042 ms 640 KB Output is correct
57 Correct 500 ms 440 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 0 ms 256 KB Output is correct
60 Runtime error 1 ms 384 KB Execution killed with signal 8
61 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 15 ms 384 KB Output is correct
27 Correct 13 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 30 ms 388 KB Output is correct
32 Correct 17 ms 384 KB Output is correct
33 Correct 13 ms 384 KB Output is correct
34 Correct 1 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 1 ms 256 KB Output is correct
40 Correct 6 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 1 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 ms 256 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 263 ms 444 KB Output is correct
51 Correct 204 ms 384 KB Output is correct
52 Correct 308 ms 384 KB Output is correct
53 Correct 244 ms 504 KB Output is correct
54 Correct 53 ms 512 KB Output is correct
55 Correct 1037 ms 556 KB Output is correct
56 Correct 1042 ms 640 KB Output is correct
57 Correct 500 ms 440 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 0 ms 256 KB Output is correct
60 Runtime error 1 ms 384 KB Execution killed with signal 8
61 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 15 ms 384 KB Output is correct
27 Correct 13 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 30 ms 388 KB Output is correct
32 Correct 17 ms 384 KB Output is correct
33 Correct 13 ms 384 KB Output is correct
34 Correct 1 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 1 ms 256 KB Output is correct
37 Correct 7 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 1 ms 256 KB Output is correct
40 Correct 6 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 1 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 ms 256 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 263 ms 444 KB Output is correct
51 Correct 204 ms 384 KB Output is correct
52 Correct 308 ms 384 KB Output is correct
53 Correct 244 ms 504 KB Output is correct
54 Correct 53 ms 512 KB Output is correct
55 Correct 1037 ms 556 KB Output is correct
56 Correct 1042 ms 640 KB Output is correct
57 Correct 500 ms 440 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 0 ms 256 KB Output is correct
60 Runtime error 1 ms 384 KB Execution killed with signal 8
61 Halted 0 ms 0 KB -