Submission #251918

#TimeUsernameProblemLanguageResultExecution timeMemory
251918anubhavdharToys (CEOI18_toy)C++14
100 / 100
677 ms4600 KiB
#include<bits/stdc++.h> #define ll long long int #define pb push_back #define mp make_pair #define FOR(i,n) for(i=0;i<(n);++i) #define FORe(i,n) for(i=1;i<=(n);++i) #define FORr(i,a,b) for(i=(a);i<(b);++i) #define FORrev(i,n) for(i=(n);i>=0;--i) #define F0R(i,n) for(int i=0;i<(n);++i) #define F0Re(i,n) for(int i=1;i<=(n);++i) #define F0Rr(i,a,b) for(ll i=(a);i<(b);++i) #define F0Rrev(i,n) for(int i=(n);i>=0;--i) #define ii pair<ll,ll> #define vi vector<ll> #define vii vector<ii> #define ff first #define ss second #define cd complex<double> #define vcd vector<cd> #define ldd long double #define dbgLine cerr<<"Line : "<<__LINE__<<'\n' #define all(x) (x).begin(),(x).end() using namespace std; const short int __PRECISION = 10; const ll MOD = 1e9+7; const ll INF = 1e17 + 1101; const ll LOGN = 17; const ll MAXN = 2e5+5; const ll ROOTN = 320; const ldd PI = acos(-1); const ldd EPS = 1e-7; set<int> Answer; vector<int> stk; void fact(int n, int f) { // cerr<<"in fact("<<n<<','<<f<<")\n"; stk.pb(f); if(n == 1) { int ans = 0; for(int v : stk) ans += v-1; Answer.insert(ans); stk.pop_back(); return; } if(f > n) { stk.pop_back(); return; } fact(1, n); for(int i = f; i*i <= n; ++i) if(n%i == 0) fact(n/i, i); stk.pop_back(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; if(n == 1) { cout<<"1\n0\n"; exit(0); } fact(1, n); for(int i = 2; i*i <= n; ++i) if(n%i == 0) fact(n/i, i); cout<<Answer.size()<<'\n'; for(int v : Answer) cout<<v<<' '; return 0; }
#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...