Submission #1094995

# Submission time Handle Problem Language Result Execution time Memory
1094995 2024-10-01T06:54:14 Z alexander707070 Toys (CEOI18_toy) C++14
0 / 100
24 ms 55900 KB
#include<bits/stdc++.h>
#define MAXN 1007
using namespace std;

int n;
vector<int> dels;

unordered_set<int> sums[MAXN][MAXN];

unordered_map<int,int> pos;

unordered_set<int> ans;

unordered_set<int> ff(int d,int mins){
	if(mins>d)return {dels[d]-1};
	if(dels[d]%dels[mins]!=0)return ff(d,mins+1);

	if(!sums[d][mins].empty())return sums[d][mins];

	sums[d][mins] = ff(d,mins+1);
	unordered_set<int> s=ff(pos[dels[d]/dels[mins]],mins);

	for(int i:s){
		sums[d][mins].insert(i+dels[mins]-1);
	}

	return sums[d][mins];
}

int main(){

	cin>>n;
	for(int i=1;i*i<=n;i++){
		if(n%i!=0)continue;

		dels.push_back(i);
		if(i!=n/i)dels.push_back(n/i);
	}

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

	for(int i=0;i<dels.size();i++){
		pos[dels[i]]=i;
	}
	
	ans=ff(dels.size()-1,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:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i=0;i<dels.size();i++){
      |              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 23 ms 55900 KB Output is correct
2 Correct 22 ms 55900 KB Output is correct
3 Correct 22 ms 55864 KB Output is correct
4 Correct 23 ms 55900 KB Output is correct
5 Correct 23 ms 55900 KB Output is correct
6 Correct 22 ms 55896 KB Output is correct
7 Correct 24 ms 55900 KB Output is correct
8 Incorrect 22 ms 55760 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 55900 KB Output is correct
2 Correct 22 ms 55900 KB Output is correct
3 Correct 22 ms 55864 KB Output is correct
4 Correct 23 ms 55900 KB Output is correct
5 Correct 23 ms 55900 KB Output is correct
6 Correct 22 ms 55896 KB Output is correct
7 Correct 24 ms 55900 KB Output is correct
8 Incorrect 22 ms 55760 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 55900 KB Output is correct
2 Correct 22 ms 55900 KB Output is correct
3 Correct 22 ms 55864 KB Output is correct
4 Correct 23 ms 55900 KB Output is correct
5 Correct 23 ms 55900 KB Output is correct
6 Correct 22 ms 55896 KB Output is correct
7 Correct 24 ms 55900 KB Output is correct
8 Incorrect 22 ms 55760 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 55900 KB Output is correct
2 Correct 22 ms 55900 KB Output is correct
3 Correct 22 ms 55864 KB Output is correct
4 Correct 23 ms 55900 KB Output is correct
5 Correct 23 ms 55900 KB Output is correct
6 Correct 22 ms 55896 KB Output is correct
7 Correct 24 ms 55900 KB Output is correct
8 Incorrect 22 ms 55760 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 55900 KB Output is correct
2 Correct 22 ms 55900 KB Output is correct
3 Correct 22 ms 55864 KB Output is correct
4 Correct 23 ms 55900 KB Output is correct
5 Correct 23 ms 55900 KB Output is correct
6 Correct 22 ms 55896 KB Output is correct
7 Correct 24 ms 55900 KB Output is correct
8 Incorrect 22 ms 55760 KB Output isn't correct
9 Halted 0 ms 0 KB -