Submission #1243380

#TimeUsernameProblemLanguageResultExecution timeMemory
1243380DangKhoizzzzToys (CEOI18_toy)C++17
100 / 100
824 ms4440 KiB
/*
8 6 5
hi welcome hello ihateyou goaway dog cat rat
1 hi welcome
1 ihateyou goaway
2 hello ihateyou
2 hi goaway
2 hi hello
1 hi hello
dog cat
dog hi
hi hello
ihateyou goaway
welcome ihateyou
*/

#include <bits/stdc++.h>
#define pii pair <int , int>
#define fi first
#define se second
#define pii pair <int , int> 


using namespace std;

const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;

set <int> s;

void dfs(int x , int n , int sum)
{
    s.insert(sum + n-1);
    int r = x;
    while(r*r <= n)
    {
        if(n%r == 0)
        {
            int y = n/r;
            if(y > r) dfs(y , n/y , sum + (y-1));
            dfs(r , n/r , sum + (r-1));
        }
        r++;
    }
}

void solve()
{
    int n;
    cin >> n;
    dfs(2 , n , 0);
    cout << s.size() << '\n';
    for(int x: s) cout << x << ' ';
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}
#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...