Submission #942949

#TimeUsernameProblemLanguageResultExecution timeMemory
942949vjudge1Toys (CEOI18_toy)C++17
59 / 100
5045 ms908 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() const int INF = 1e18,N = 1e5 + 1; const int p = 911382323, m = 972663749; int binpow (int a, int n) { if (n == 0) return 1; if (n % 2 == 1) return (binpow(a, n - 1) * (a)); else { int b = binpow(a, n / 2); return (b * b) ; } } set<int> res; map<int,bool> vis; void when(int n,int sum){ sum += n - 1; res.insert(sum); sum -= n - 1; for(int dv = 1;dv <= n;dv++){ if(dv == 1){ continue; } if(n % dv == 0){ sum += dv - 1; when(n / dv,sum); sum -= dv - 1; } } } void solve(){ int n; cin >> n; when(n,0); cout << res.size() << "\n"; for(auto i : res){ cout << i << " "; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0),cout.tie(0); int t = 1; //~ cin >> t; while(t--){ solve(); } }
#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...