Submission #405352

#TimeUsernameProblemLanguageResultExecution timeMemory
405352ollelToys (CEOI18_toy)C++14
59 / 100
139 ms262148 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back int n; vvi d; vector<set<int>> dp; void getd(){ d.resize(n+1); rep(i, 2, n+1){ int x = 2*i; while (x < n+1) {d[x].pb(i); x += i;} } } set<int> get(int x) { if (!(dp[x].empty())) return dp[x]; dp[x].insert(x - 1); for (auto &y : d[x]) { for (auto &k : get(x/y)) { dp[x].insert(k + y - 1); } } return dp[x]; } int main(){ cin >> n; getd(); dp.resize(n+1); set<int> ans = get(n); cout << ans.size() << endl; for (auto &i : ans) cout << i << " "; cout<<endl; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:43:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   43 |   for (auto &i : ans) cout << i << " "; cout<<endl;
      |   ^~~
toy.cpp:43:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   43 |   for (auto &i : ans) cout << i << " "; cout<<endl;
      |                                         ^~~~
#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...