Submission #1053484

#TimeUsernameProblemLanguageResultExecution timeMemory
1053484VMaksimoski008Toys (CEOI18_toy)C++17
100 / 100
1254 ms86512 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> div; for(int i=1; i*i<=n; i++) { if(n % i > 0) continue; div.push_back(i); if(n / i != i) div.push_back(n/i); } map<int, int> mp; sort(div.begin(), div.end()); for(int i=0; i<div.size(); i++) mp[div[i]] = i; int m = div.size(); set<int> dp[m]; dp[0].insert(0); for(int i=1; i<m; i++) { for(int j=1; j*j<=div[i]; j++) { if(div[i] % j == 0 && j > 1) for(auto &x : dp[mp[div[i]/j]]) dp[i].insert(x+j-1); if(div[i] % j == 0 && div[i] / j > 1) for(auto &x : dp[mp[j]]) dp[i].insert(x+(div[i]/j)-1); } } cout << dp[m-1].size() << '\n'; for(auto &x : dp[m-1]) cout << x << " "; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0; i<div.size(); i++) mp[div[i]] = i;
      |                  ~^~~~~~~~~~~
#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...