Submission #536879

#TimeUsernameProblemLanguageResultExecution timeMemory
536879chicken337Toys (CEOI18_toy)C++14
79 / 100
5060 ms39436 KiB
#include <bits/stdc++.h> using namespace std; set<pair<int, int>> vis; void backtrack(int n, int sum){ if(vis.find({n, sum}) != vis.end()) return; vis.insert({n, sum}); for(int k = 2; k <= sqrt(n); k ++){ int div = n / k; if((div * k) == n) backtrack(div, sum + k - 1), backtrack(k, sum + div - 1); } if(n != 1) backtrack(1, sum + n - 1); } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; backtrack(n, 0); set<int> unique; for(auto &[num, sum] : vis) if(num == 1) unique.insert(sum); cout << unique.size() << '\n'; for(int it : unique) cout << it << ' '; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:28:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |     for(auto &[num, sum] : vis)
      |               ^
#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...