Submission #267057

# Submission time Handle Problem Language Result Execution time Memory
267057 2020-08-15T18:36:59 Z Kenzo_1114 Toys (CEOI18_toy) C++17
19 / 100
5000 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXV = 40;

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

void BKT(int sum, int last, int qtt)
{
	if(marc == (1 << sz) - 1)
	{
		ans.insert(sum + last - qtt);
		return;
	}

	for(int i = 0; i < sz; i++)
	{
		if(marc & (1 << i))	continue;

		marc += (1 << i);
		if(qtt)	BKT(sum, last * v[i], qtt);
		BKT(sum + last, v[i], qtt + 1);
		marc -= (1 << i);
	}
}

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

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

	sz = v.size();
	sort(v.begin(), v.end());

	BKT(0, 0, 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 'int main()':
toy.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |  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 0 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 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 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 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 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 0 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 0 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 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 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 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 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 0 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 283 ms 368 KB Output is correct
27 Correct 273 ms 376 KB Output is correct
28 Correct 17 ms 256 KB Output is correct
29 Correct 16 ms 372 KB Output is correct
30 Correct 2 ms 368 KB Output is correct
31 Execution timed out 5084 ms 256 KB Time limit exceeded
32 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 0 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 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 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 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 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 0 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 283 ms 368 KB Output is correct
27 Correct 273 ms 376 KB Output is correct
28 Correct 17 ms 256 KB Output is correct
29 Correct 16 ms 372 KB Output is correct
30 Correct 2 ms 368 KB Output is correct
31 Execution timed out 5084 ms 256 KB Time limit exceeded
32 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 0 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 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 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 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 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 0 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 283 ms 368 KB Output is correct
27 Correct 273 ms 376 KB Output is correct
28 Correct 17 ms 256 KB Output is correct
29 Correct 16 ms 372 KB Output is correct
30 Correct 2 ms 368 KB Output is correct
31 Execution timed out 5084 ms 256 KB Time limit exceeded
32 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 0 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 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 380 KB Output is correct
13 Correct 1 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 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 1 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 0 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 283 ms 368 KB Output is correct
27 Correct 273 ms 376 KB Output is correct
28 Correct 17 ms 256 KB Output is correct
29 Correct 16 ms 372 KB Output is correct
30 Correct 2 ms 368 KB Output is correct
31 Execution timed out 5084 ms 256 KB Time limit exceeded
32 Halted 0 ms 0 KB -