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 all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define print(x) cout << #x << " est " << x << endl;
#define x first
#define y second
//#define int long long
using namespace std;
map<int, set<int>> dp;
void calcul(int produit){
if (dp[produit].empty()){
dp[produit].insert(produit - 1);
for (int div = 2; div * div <= produit; ++div){
if (produit%div == 0){
int comp = produit/div;
calcul(div);
calcul(comp);
for (int sum : dp[div])
dp[produit].insert(sum + comp - 1);
for (int sum : dp[comp])
dp[produit].insert(sum + div - 1);
}
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int produit; cin >> produit;
calcul(produit);
cout << sz(dp[produit]) << endl;
for (int somme : dp[produit])
cout << somme << " " ;
cout << endl;
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... |