제출 #1261332

#제출 시각아이디문제언어결과실행 시간메모리
1261332son2008Toys (CEOI18_toy)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
#define fi first
#define se second
#define int long long
#define ll long long
#define ld double
#define mp make_pair
#define lg2 30
#define iii pair<int, ii>
#define iiii pair<ii, ii>
#define base 29
#define eps 1e-8
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
int dx[] = {0LL, 0LL, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0LL, 0LL, 1, -1, 1, -1};
const int maxn = 4e5 + 5;
const int mod = 1e9 + 7;
int n;
vector<int> ans;
void dfs(int x, int cuoi, int sum)
{
    if (x >= cuoi)
    {
        ans.push_back(sum + x - 1);
    }
    for (int i = cuoi; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            dfs(x / i, i, sum + i - 1);
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    dfs(n, 2, 0);
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout << ans.size() << '\n';
    for (int x : ans)
    {
        cout << x << " ";
    }
    cerr << endl
         << "TIME : " << clock() * 0.001 << "s" << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...