# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748650 | mariowong | Toys (CEOI18_toy) | C++14 | 765 ms | 20716 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;
int n;
vector <int> fac;
unordered_map <int,vector<int> > m;
unordered_map <int,int> now;
int main(){
ios::sync_with_stdio(false);
cin >> n;
m.reserve(1000000);
for (int i=1;i*i<=n;i++){
if (n%i == 0){
if (n/i != i)
fac.push_back(n/i);
fac.push_back(i);
}
}
sort(fac.begin(),fac.end());
for (int i=0;i<fac.size();i++){
now.clear(); now[fac[i]-1]=true;
m[fac[i]].push_back(fac[i]-1);
for (int j=0;j<i;j++){
if (fac[i]%fac[j] == 0){
for (int k=0;k<m[fac[j]].size();k++){
if (!now[m[fac[j]][k]+fac[i]/fac[j]-1]){
now[m[fac[j]][k]+fac[i]/fac[j]-1]=true;
m[fac[i]].push_back(m[fac[j]][k]+fac[i]/fac[j]-1);
}
}
}
}
}
sort(m[n].begin(),m[n].end());
cout << (int)m[n].size() << "\n";
for (int i=0;i<m[n].size();i++){
cout << m[n][i] << " ";
}
cout << "\n";
return 0;
}
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... |