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;
#pragma GCC optmize("O3")
typedef int ll;
typedef long double ld;
#define vii vector<pair<int, int>>
#define vi vector<int>
#define vl vector<long long>
#define vll vector<pair<long long, long long>>
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = a;i<=b;i++)
#define f first
#define s second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define start int tt;cin>>tt;rep(testcase, 1, tt)
#define print(k) cout<<"Case #"<<testcase<<": "<<k<<"\n";
#define endl "\n"
set<ll> ans;
void solve(ll n, ll k, ll sum) {
ans.insert(sum + n -1);
for(int i = k;i*i<= n;i++) {
if(n%i == 0) {
solve(n/i, i, sum + i -1);
}
}
}
int main () {
//FIO;
/*#ifndef ONLINE_JUDGE
freopen("stdin", "r", stdin);
freopen("stdout", "w", stdout);
freopen("stderr", "w", stderr);
#endif*/
int n;
scanf("%d", &n);
solve(n, 2, 0);
printf("%d\n", int(ans.size()));
for(int i:ans) {
printf("%d ", i);
}
return 0;
}
// :"D
Compilation message (stderr)
toy.cpp:3: warning: ignoring '#pragma GCC optmize' [-Wunknown-pragmas]
3 | #pragma GCC optmize("O3")
|
toy.cpp: In function 'int main()':
toy.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
# | 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... |