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;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
bool prime[100005];
int n;
int main(){
scanf("%d",&n);
vector<pair<int,ll> > v;
v.pb(n,0);
for(int i=2;i<=100005;i++){
for(int j=0;j<SZ(v);j++){ // it should include the new elements
pair<int,ll> x=v[j];
if(x.fi%i==0){
v.pb(x.fi/i,i-1+x.se);
}
}
}
if(SZ(v)==1)v.pb(1,n-1);
set<ll> ans;
for(pair<int,ll> i:v){
if(i.fi==1)ans.insert(i.se);
}
printf("%d\n",SZ(ans));
for(auto it=ans.begin();it!=ans.end();++it){
printf("%lld ",(*it));
}
}
Compilation message (stderr)
toy.cpp: In function 'int main()':
toy.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | 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... |