Submission #537962

# Submission time Handle Problem Language Result Execution time Memory
537962 2022-03-16T00:55:33 Z TaylorSwiftFangirl Toys (CEOI18_toy) C++17
0 / 100
123 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> f;
int m;

vector<vector<int> > comb(int x) {
	if(x==0) {
		vector<int>v{f[0]};
		return (vector<vector<int> >){v};
	}
	vector<vector<int> > a = comb(x-1), b;
	int k = a.size();
	for(int i=0; i<k; i++) {
		a[i].push_back(f[x]);
		b.push_back(a[i]);
		a[i].pop_back();
	}
	for(int i=0; i<k; i++) {
		for(int j=0; j<(int)a[i].size();j++) {
			if(j>0 && a[i][j]==a[i][j-1]) continue;
			a[i][j]*=f[x];
			b.push_back(a[i]);
			a[i][j]/=f[x];
		}
	}
	return b;
}

int main() {
	int n;
	cin >> n;
	
	for(int i=2; i*i<=n; i++) {
		while(n%i==0) {
			f.push_back(i);
			n/=i;
		}
	}
	if(n!=1) f.push_back(n);
		
	vector<vector<int> > v = comb(f.size()-1);
	
	set<int> s;
	for(auto i : v) {
		int tot = 0;
		for(auto j : i) tot += j-1;
		s.insert(tot);
	}
	cout << s.size() << '\n';
	for(auto i : s) {
		cout << i << ' ';
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 123 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -