이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long
unordered_map<int, map<int, bool> > mp;
vector<int> ans;
int sum = 0;
void f(int n){
mp[n][sum] = true;
if(n == 1){
ans.push_back(sum);
return;
}
int x = n;
sum = sum + x - 1;
if(!mp[n/x][sum]) f(n / x);
sum = sum - x + 1;
for(int d = 2; d * d <= n; d++){
if(n % d == 0){
x = d;
sum = sum + x - 1;
if(!mp[n/x][sum]) f(n / x);
sum = sum - x + 1;
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n; cin >> n;
f(n);
sort(all(ans));
cout << ans.size() << '\n';
for(auto x : ans) cout << x << ' ';
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... |