# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
490997 | 2021-11-30T03:06:43 Z | baokhue232005 | Toys (CEOI18_toy) | C++14 | 1 ms | 204 KB |
/* #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") */ // lethal option #include<bits/stdc++.h> using namespace std; #define all(flg) flg.begin(), flg.end() #define int long long #define pb push_back #define fi first #define se second // #define endl "\n" #define eb emplace_back #define ii pair<int, int> #define PI 3.141592653589793238462643383279502884 #define ll long long #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i) #define for2(i, ff, gg) for(int i = ff; i >= gg; --i) const ll mod = 1e9 + 7; const int maxN = 300005; const ll oo = 1e18 + 7; int n, a[maxN]; int x, y, z, k; vector<int> ans; vector<int> back(int god, int dnlim, int sum){ vector<int> buo; int db = sqrt(god); if(dnlim > god) return buo; buo.pb(sum + god - 1); for1(i, dnlim, db) if(god % i == 0){ auto cm = back(god / i, i, sum + i - 1); buo.insert(buo.end(), all(cm)); } // cout << god << " " << dnlim << ' ' << sum << "\n"; // for(int cc : buo) cout << cc << " "; // cout << endl; return buo; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n; if(n == 1){ cout << "0\n\n"; return 0; } ans = back(n, 2, 0); sort(all(ans)); int vl = 0; for1(i, 0, ans.size() - 1){ if(i == 0 || ans[i] != ans[i - 1]) ++vl; } cout << vl << endl; for1(i, 0, ans.size() - 1){ if(i == 0 || ans[i] != ans[i - 1]) cout << ans[i] << " "; } cout << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |