# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934358 | tamir1 | Toys (CEOI18_toy) | C++14 | 2123 ms | 86960 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>
#define ll long long
using namespace std;
ll n,i,j,m,x,y;
vector<ll> a,b;
vector<set<ll>> s;
map<ll,ll> mp;
int main(){
cin >> n;
for(i=1;i*i<=n;i++){
if(n%i!=0) continue;
if(i*i==n){
a.push_back(i);
continue;
}
a.push_back(i);
b.push_back(n/i);
}
for(i=b.size()-1;i>=0;i--) a.push_back(b[i]);
for(i=0;i<a.size();i++) mp[a[i]]=i;
m=a.size();
s=vector<set<ll>> (m);
for(i=0;i<m;i++){
x=a[i];
s[i].insert(x-1);
for(j=0;j<i;j++){
y=a[j];
if(x%y!=0) continue;
ll add=x/y-1;
for(ll l:s[j]){
s[i].insert(l+add);
}
}
}
cout << s[m-1].size() << "\n";
for(ll i:s[m-1]) cout << i << " ";
}
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... |