Submission #1214170

#TimeUsernameProblemLanguageResultExecution timeMemory
1214170vako_pToys (CEOI18_toy)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define sd second
#define debug(x) cerr << #x << "----> " << x << endl;
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3")

const int mxN = 1e6 + 5;
ll n,cc = 0;
bitset<100000000> vis;
vector<ll> ans;

void f(ll x, ll val = 0){
	cc++;
	if(!vis[val + x - 1]){
		ans.pb(val + x - 1);
		vis[val + x - 1] = true;
	}
	for(int i = 2; i <= sqrtl(x); i++){
		if(x % i == 0){
			ll k = i;
			f(x / k, val + k - 1);
			k = x / i;
			f(x / k, val + k - 1);
		} 
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	f(n);
	debug(cc);
	cout << ans.size() << '\n';
	for(auto it : ans) cout << it << ' ';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...