Submission #934289

# Submission time Handle Problem Language Result Execution time Memory
934289 2024-02-27T06:20:19 Z tamir1 Toys (CEOI18_toy) C++14
0 / 100
1 ms 604 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,j,m,x,y;
vector<ll> a,b;
set<ll> s[1001];
map<ll,ll> mp;
int main(){
	cin >> n;
	for(i=1;i*i<=n;i++){
		if(n%i!=0) continue;
		if(i*i==n){
			a.push_back(i);
			continue;
		}
		a.push_back(i);
		b.push_back(n/i);
	}
	for(i=b.size()-1;i>=0;i--) a.push_back(b[i]);
	for(i=0;i<a.size();i++) mp[a[i]]=i;
	m=a.size();
	for(i=0;i<m;i++){
		x=a[i];
		s[i].insert(x-1);
		for(j=1;a[j]*a[j]<=a[i];j++){
			y=a[j];
			if(x%y!=0) continue;
			for(ll l:s[mp[y]]){
				for(ll r:s[mp[x/y]]){
					s[i].insert(l+r);
				}
			}
		}
	}
	cout << s[m-1].size() << "\n";
	for(ll i:s[m-1]) cout << i << " ";
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:20:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(i=0;i<a.size();i++) mp[a[i]]=i;
      |          ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -