This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// ~Be name khoda~ //
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define cl clear
#define endll '\n'
const int maxn = 1e6 + 10;
const int maxn5 = 1e6 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 2e18;
set <int> av[maxn5];
map <int, int> ind;
int newnode = 0;
inline void solve(int n){
ind[n] = newnode++;
int vn = ind[n];
av[vn].insert(n - 1);
for(int i = 2; i * i <= n; i++) if(n % i == 0){
if(ind.find(n / i) == ind.end()) solve(n / i);
int vi = ind[n / i];
for(auto it = av[vi].begin(); it != av[vi].end(); it++)
av[vn].insert((*it) + i - 1);
}
return;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n; cin >> n;
solve(n);
int vn = ind[n];
cout << av[vn].size() << '\n';
for(auto it = av[vn].begin(); it != av[vn].end(); it++) cout << *it << ' ';
cout << endl;
}
# | 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... |