Submission #490964

#TimeUsernameProblemLanguageResultExecution timeMemory
490964Mike4235Toys (CEOI18_toy)C++17
79 / 100
5092 ms60700 KiB
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define for1(i,a,b) for (int i = a; i <= b; i++) #define for2(i,a,b) for (int i = a; i >= b; i--) // #define int long long #define sz(a) (int)a.size() #define pii pair<int,int> #define pb push_back /* __builtin_popcountll(x) : Number of 1-bit __builtin_ctzll(x) : Number of trailing 0 */ const long double PI = 3.1415926535897932384626433832795; const int INF = 1000000000000000000; const int MOD = 1000000007; const int MOD2 = 1000000009; const long double EPS = 1e-6; using namespace std; int n; map<int, vector<int>> mp; map<pii, bool> flag; vector<int> v; void solve(int x, int sum) { if (flag[{x, sum}]) return; flag[{x, sum}] = 1; v.push_back(sum + x - 1); if (mp.find(x) != mp.end()) { for (auto i : mp[x]) solve(i, sum + x / i - 1); } else { for (int i = 2; i * i <= x; i++) if (x % i == 0) { if (i * i == x) { mp[x].push_back(i); solve(i, sum + i - 1); } else { mp[x].push_back(i); mp[x].push_back(x / i); solve(i, sum + x / i - 1); solve(x / i, sum + i - 1); } } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("cf.inp", "r", stdin); // freopen("cf.out", "w", stdout); cin >> n; solve(n, 0); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); cout << sz(v) << "\n"; for (auto x : v) cout << x << " "; }

Compilation message (stderr)

toy.cpp:21:17: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   21 | const int INF = 1000000000000000000;
      |                 ^~~~~~~~~~~~~~~~~~~
#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...