답안 #470911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
470911 2021-09-06T07:48:35 Z prvocislo Toys (CEOI18_toy) C++17
0 / 100
1 ms 204 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

void divisors(int n, vector<int> &di)
{
	for (int i = 1; i * i <= n; i++) if (n % i == 0)
	{
		di.push_back(i);
		if (n / i != i) di.push_back(n / i);
	}
	sort(di.begin(), di.end());
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v;
	divisors(n, v);
	int k = v.size();
	vector<vector<int> > d(v.size());
	for (int i = 0; i < v.size(); i++)
	{
		divisors(v[i], d[i]);
		for (int j = 0; j < d[i].size(); j++) d[i][j] = lower_bound(v.begin(), v.end(), d[i][j]) - v.begin();
	}
	vector<vector<int> > mul(k, vector<int>(k, -1));
	for (int i = 0; i < k; i++) for (int j : d[k - 1 - i])
	{
		int x = v[i] * v[j];
		mul[i][j] = lower_bound(v.begin(), v.end(), x) - v.begin();
	}
	vector<set<int> > dp(k);
	dp[0].insert(0);
	set<int> ans;
	for (int i = 1; i < k; i++)
	{
		if (i <= (k - 1) / 2)
		{
			for (int m : d[k - 1 - i])
			{
				for (int s : dp[m])
				{
					dp[mul[i][m]].insert(s + v[i] - 1);
				}
			}
		}
		for (int s : dp[k - 1 - i])
		{
			ans.insert(s + v[i] - 1);
		}
	}
	cout << ans.size() << "\n";
	for (int i : ans) cout << i << " ";
	cout << "\n";
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
toy.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for (int j = 0; j < d[i].size(); j++) d[i][j] = lower_bound(v.begin(), v.end(), d[i][j]) - v.begin();
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -