이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18
#define ret return
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
unordered_map <int, unordered_set<int> > dp;
void solve(int n){
	dp[n].insert(n-1);
	for(int i = 2; i <= sqrt(n); i++){
		if(n%i==0){
			if(dp[i].empty())solve(i);
			if(dp[n/i].empty())solve(n/i);
			for(auto it: dp[i]){
				for(auto itt: dp[n/i]){
					dp[n].insert(it+itt);
				}
			}
		}
	}
}
vi ans;
int main(){
	int n;
	cin >> n;
	dp.max_load_factor(0.25);dp.reserve(512);
	if(n==1){
		cout << 1 << '\n' << 0;
		ret 0;
	}
	solve(n);
	cout << dp[n].size() << endl;
	for(auto it: dp[n]){
		ans.pb(it);
	}
	sort(ans.begin(),ans.end());
	n = ans.size();
	for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
}
| # | 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... |