Submission #822935

# Submission time Handle Problem Language Result Execution time Memory
822935 2023-08-12T05:25:32 Z MohamedAhmed04 Toys (CEOI18_toy) C++14
0 / 100
48 ms 94636 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 2004 ;

int n ;

vector<int>divi ;

vector<int>dp[MAX][MAX] ;
vector<int>Div[MAX] ;

vector<int>factorize(int x)
{
	vector<int>v ;
	for(int i = 1 ; i * i <= x ; ++i)
	{
		if(x%i == 0)
		{
			v.push_back(i) ;
			if(i*i != x)
				v.push_back(x/i) ;
		}
	}
	divi.push_back(1) ;
	sort(v.begin() , v.end()) ;
	return v ;
}

map<int , int>mp ;
vector<int>dp2[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector<int>divi = factorize(n) ;
	int sz = divi.size() ;
	for(int i = 0 ; i < sz ; ++i)
	{
		Div[i] = factorize(divi[i]) ;
		mp[divi[i]] = i ;
	}
	for(int j = 0 ; j < sz ; ++j)
		dp[0][j] = {divi[j]-1} ;
	for(int i = 1 ; i < sz ; ++i)
	{
		dp[i][0] = {divi[i]-1} , dp2[i].push_back(divi[i]-1) ;
		for(int j = 1 ; j <= i ; ++j)
		{
			if(n % (1ll * divi[i] * divi[j]) != 0)
				continue ;
			for(auto &x : Div[i])
			{
				if(mp[x] >= j)
				{
					int idx = mp[divi[i] / x] , idx2 = mp[x] ;
					for(auto &k : dp[idx][idx2])
						dp[i][j].push_back(k) ;
				}
			}
			sort(dp[i][j].begin() , dp[i][j].end()) ;
			dp[i][j].erase(unique(dp[i][j].begin() , dp[i][j].end()) , dp[i][j].end()) ;
			int idx = mp[divi[i] * divi[j]] ;
			for(auto &x : dp[i][j])
				x += divi[j]-1 , dp2[idx].push_back(x) ;
		}
		sort(dp2[i].begin() , dp2[i].end()) ;
		dp2[i].erase(unique(dp2[i].begin() , dp2[i].end()) , dp2[i].end()) ;
	}
	cout<<dp2[sz-1].size()<<"\n" ;
	for(auto &x : dp2[sz-1])
		cout<<x<<" " ;
	cout<<"\n" ;
	return 0 ;
}
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 94636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 94636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 94636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 94636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 94636 KB Output isn't correct
2 Halted 0 ms 0 KB -