This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mp make_pair
#define mid (l+r)/2
#define le node * 2
#define ri node * 2 + 1
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=1e18;
const ll mod=998244353;
const ld Pi=acos(-1) ;
int n ;
vi v ;
int num [29] ;
set < int > s ;
void bt ( int pos , int k ) {
if ( pos == v .size () ) {
int ans = 0 ;
for ( int i = 1 ; i <= k ; i ++ ) {
ans += num [i] - 1 ;
}
s .ins ( ans ) ;
return ;
}
for ( int i = 1 ; i <= k ; i ++ ) {
num [i] *= v [pos] ;
bt ( pos + 1 , k ) ;
num [i] /= v [pos] ;
}
}
int main () {
cin >> n ;
for ( int i = 2 ; i * i <= n ; i ++ ) {
if ( n % i == 0 ) {
while ( n % i == 0 ) {
v .pb ( i ) ;
n /= i ;
}
}
}
if ( n != 1 ) v .pb ( n ) ;
for ( int i = 1 ; i <= v .size () ; i ++ ) num [i] = 1 ;
bt ( 0 , v .size () ) ;
cout << s.size () << endl ;
for ( auto u : s ) cout << u << " " ;
cout << endl ;
}
Compilation message (stderr)
toy.cpp: In function 'void bt(int, int)':
toy.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if ( pos == v .size () ) {
| ~~~~^~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:65:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for ( int i = 1 ; i <= v .size () ; i ++ ) num [i] = 1 ;
| ~~^~~~~~~~~~~~~
# | 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... |