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 pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2000 + 10;
const ll mod = 1e9 + 7;
ll um(ll a, ll b){
return ((1LL * a * b) % mod + mod) % mod;
}
ll subr(ll a, ll b){
return ((1LL * a - b) % mod + mod) % mod;
}
ll binpow(ll x, ll step){
ll res = 1LL;
while(step){
if(step & 1) res = um(res, x);
x = um(x, x);
step /= 2;
}
return res;
}
map <ll, bool> mp;
void calc(ll cur, ll x, ll sum){
//cout << cur << " "<< x << " "<< sum << endl;
if(cur == 1){
mp[sum] = true;
return;
}
for(ll i = 2; i * i <= cur; i++){
if(cur % i == 0){
if(i >= x) calc(cur / i, i, sum + i - 1);
if(cur/i != i && cur / i > x) calc(i, i, sum + cur/i - 1);
}
}
if(cur >= x) calc(1, cur, sum + cur - 1);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
calc(n, 1, 0);
cout << mp.size() << endl;
for(auto u : mp){
cout << u.F << " ";
}
return 0;
}
# | 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... |