# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1051489 | anton | Toys (CEOI18_toy) | C++17 | 5063 ms | 852 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N;
vector<int> factorize(int n){
vector<int> res;
for(int i = 2; i*i<=n;i++){
if(n%i == 0){
res.push_back(i);
if(i*i!=n){
res.push_back(n/i);
}
}
}
res.push_back(n);
return res;
}
void recur(int pos, int max_c, vector<vector<int>>& res, vector<int>& cur){
if(pos == cur.size()){
res.push_back(cur);
return;
}
for(int i = 0; i<max_c; i++){
cur[pos] = i;
recur(pos+1, max_c, res, cur);
}
}
set<int> sums(int n){
set<int> res;
if(n==1){
res.insert(0);
return res;
}
auto factors = factorize(n);
for(auto e: factors){
auto ch_s = sums(n/e);
for(auto ee: ch_s){
res.insert(ee+e-1);
}
}
return res;
}
signed main(){
cin>>N;
auto possib = sums(N);
cout<<possib.size()<<endl;
for(auto e: possib){
cout<<e<<" ";
}
cout<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |