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>
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
set<int>res;
int n;
void test(int x, int sum){
if(x==n){
res.insert(sum);
return;
}else if(x>n)return;
for(int i=1;i<=n/x;++i){
if(n%x*(i+1)!=0)continue;
test(x*(i+1),sum+i);
}
}
int main(){_
cin>>n;
// int sq = sqrt(n)+1;
// int tmp = n;
// vector<int>factors;
// for(int i=2;i<=sq;++i){
// while(tmp%i==0){
// factors.pb(i);
// tmp/=i;
// }
// }
// if(tmp!=1)factors.pb(tmp);
test(1,0);
cout<<sz(res)<<endl;
for(auto x:res)cout<<x<<" ";
}
# | 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... |