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 <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
#include<set>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
//#define maxn 100005
vector<int> ans;
void rec( int rem, int sum, int from )
{
ans.pb( sum + rem-1 );
for( int i=from; (i*i) <= rem;i++ ){
if( rem%i==0 ){
rec( rem/i, sum+i-1, i );
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
rec( n, 0,2 );
sort( ans.begin(), ans.end() );
ans.erase( unique( ans.begin(), ans.end() ), ans.end() );
cout <<ans.size()<<endl;
for( int i=0;i<ans.size();i++ )
cout<<ans[i]<< " ";
cout<<endl;
return 0;
}
Compilation message (stderr)
toy.cpp: In function 'int main()':
toy.cpp:42:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for( int i=0;i<ans.size();i++ )
~^~~~~~~~~~~
# | 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... |