Submission #283219

#TimeUsernameProblemLanguageResultExecution timeMemory
283219infinite_iqToys (CEOI18_toy)C++14
19 / 100
5071 ms504 KiB
#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 , N ; int done [100009] ; vi v , ways , ans ; int crnt = 1 ; void go ( int pos ) { if ( pos == v .size () ) { ways .pb ( crnt ) ; return ; } go ( pos + 1 ) ; crnt *= v [pos] ; go ( pos + 1 ) ; crnt /= v [pos] ; } void bt ( int pos , int mul , int num ) { if ( N < mul ) return ; if ( N == mul ) { if ( done [num] ) return ; done [num] = 1 ; ans .pb ( num ) ; return ; } if ( pos == ways . size () ) return ; bt ( pos + 1 , mul , num ) ; bt ( pos + 1 , mul * ways [pos] , num + ways [pos] - 1 ) ; } int main () { cin >> n ; N = n ; for ( int i = 2 ; i * i <= n ; i ++ ) { while ( n % i == 0 ) { v .pb ( i ) ; n /= i ; } } if ( n != 1 ) v .pb ( n ) ; go ( 0 ) ; bt ( 0 , 1 , 0 ) ; cout << ans .size () << endl ; sort ( all ( ans ) ) ; for ( auto u : ans ) cout << u << " " ; cout << endl ; }

Compilation message (stderr)

toy.cpp: In function 'void go(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 'void bt(int, int, int)':
toy.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         if ( pos == ways . size () ) return ;
      |              ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...