# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920779 | Ghulam_Junaid | Toys (CEOI18_toy) | C++17 | 2150 ms | 262144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n;
vector<int> store[N];
unordered_map<int, int> id;
vector<int> divs, imp[N];
inline void F(int x){
store[id[x]].push_back(x - 1);
for (int d : imp[id[x]]){
for (int a : store[id[d]])
for (int b : store[id[x]])
store[id[d * x]].push_back(a + b);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int x = 2; x * x <= n; x ++){
if (n % x) continue;
divs.push_back(x);
if (x * x != n)
divs.push_back(n / x);
}
divs.push_back(n);
sort(divs.begin(), divs.end());
for (int i = 0; i < divs.size(); i ++){
id[divs[i]] = i;
for (int j = 0; j <= i; j ++){
long long prod = 1ll * divs[i] * divs[j];
if (prod > n)
break;
if (n % prod == 0)
imp[id[divs[i]]].push_back(divs[j]);
}
}
for (int x : divs){
sort(store[id[x]].begin(), store[id[x]].end());
store[id[x]].resize(unique(store[id[x]].begin(), store[id[x]].end()) - store[id[x]].begin());
F(x);
}
if (n == 1) store[id[n]] = {0};
cout << store[id[n]].size() << endl;
for (int x : store[id[n]])
cout << x << " ";
cout << '\n';
}
Compilation message (stderr)
# | 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... |