Submission #872786

#TimeUsernameProblemLanguageResultExecution timeMemory
872786bobbilykingToys (CEOI18_toy)C++17
59 / 100
5046 ms65192 KiB
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #include<math.h> using namespace std; typedef int ll; typedef long double ld; typedef pair<ll, ll> pl; #define K first #define V second #define G(x) ll x; cin >> x; #define GD(x) ld x; cin >> x; #define GS(s) string s; cin >> s; #define EX(x) { cout << x << '\n'; exit(0); } #define A(a) (a).begin(), (a).end() #define F(i, l, r) for (ll i = (l); i < r; ++i) #define NN #define M 1000000007 // 998244353 set<ll> vis; set<pair<vector<pl>, ll>> dp; void dfs(vector<pl> facs, ll sm){ ll ans = 0; for (const auto &[k, v]: facs) ans += v; if (!ans) { vis.insert(sm); return; } if (dp.count({facs, sm})) return; dp.emplace(facs, sm); auto gen = [&](auto&& self, ll idx, ll csm) { if (idx == facs.size()) { dfs(facs, csm + sm - 1); return; } ll prod = 1; F(j, 0, facs[idx].V+1) { facs[idx].V -= j; self(self, idx+1, prod * csm); prod = prod * facs[idx].K; facs[idx].V += j; } }; gen(gen, 0, 1); } int main(){ // freopen("a.in", "r", stdin); // freopen("a.out", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); vector<pl> facs; G(n) for (ll i = 2; i *i <=n ;++i) if (n%i == 0) { ll cnt = 0; while (n%i==0) cnt++, n/=i; facs.emplace_back(i, cnt); } if (n-1) facs.emplace_back(n, 1); dfs(facs, 0); cout << vis.size() << '\n'; for (auto x: vis) cout << x << " "; cout << '\n'; }

Compilation message (stderr)

toy.cpp: In instantiation of 'dfs(std::vector<std::pair<int, int> >, ll)::<lambda(auto:23&&, ll, ll)> [with auto:23 = dfs(std::vector<std::pair<int, int> >, ll)::<lambda(auto:23&&, ll, ll)>&; ll = int]':
toy.cpp:48:18:   required from here
toy.cpp:36:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if (idx == facs.size()) {
      |             ~~~~^~~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:68:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   68 |     for (auto x: vis) cout << x << " "; cout << '\n';
      |     ^~~
toy.cpp:68:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   68 |     for (auto x: vis) cout << x << " "; cout << '\n';
      |                                         ^~~~
#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...