Submission #1053465

#TimeUsernameProblemLanguageResultExecution timeMemory
1053465VMaksimoski008Toys (CEOI18_toy)C++17
79 / 100
5050 ms83696 KiB
#include <bits/stdc++.h> //#define int long long using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt") const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; map<pii, int> vis; set<int> ans; void f(int n, int s) { if(vis[{ n, s }]) return ; vis[{ n, s }] = 1; if(n == 1) { ans.insert(s); return ; } for(int i=1; i*i<=n; i++) { if(n % i == 0 && i > 1) f(n/i, s+i-1); if(n % i == 0 && n/i > 1) f(n/(n/i), s+(n/i)-1); } } signed main() { //a b c //(a + 1)(b + 1)(c + 1) = n //maks log(n) razlicni //baska (a + 1), (b + 1), (c + 1) | n int n; cin >> n; f(n, 0); cout << ans.size() << '\n'; for(auto &x : ans) cout << x << " "; 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...