# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
458221 | cpp219 | Toys (CEOI18_toy) | C++17 | 844 ms | 4444 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.
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e5 + 9;
const ll Log2 = 21;
const ll inf = 1e9 + 7;
set<ll> s;
vector<ll> uoc;
ll n;
void f(int n, int stop, int sum) {
s.insert(sum + n - 1);
for (int i = stop; i <= n/i; ++i)
if (n % i == 0)
f(n/i, i, sum + i - 1);
}
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
cin>>n; uoc.push_back(n);
for (ll i = 2;i <= n/i;i++){
if (n%i == 0){
uoc.push_back(i);
if (n/i != i) uoc.push_back(n/i);
}
}
sort(uoc.begin(),uoc.end()); f(n,2,0);
cout<<s.size()<<"\n";
for (auto i : s) 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... |