Submission #261826

#TimeUsernameProblemLanguageResultExecution timeMemory
261826arnold518Toys (CEOI18_toy)C++14
100 / 100
1686 ms110004 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2000; int N; vector<int> V; vector<int> dp[MAXN+10]; int getcomp(int x) { return lower_bound(V.begin(), V.end(), x)-V.begin(); } int main() { scanf("%d", &N); for(int i=1; i*i<=N; i++) { if(N%i) continue; if(i*i==N) V.push_back(i); else { V.push_back(i); V.push_back(N/i); } } sort(V.begin(), V.end()); dp[0].push_back(0); for(int i=1; i<V.size(); i++) { for(int j=0; j<i; j++) { if(V[i]%V[j]) continue; for(auto it : dp[j]) dp[i].push_back(it+V[i]/V[j]-1); } sort(dp[i].begin(), dp[i].end()); dp[i].erase(unique(dp[i].begin(), dp[i].end()), dp[i].end()); } printf("%d\n", dp[V.size()-1].size()); for(auto it : dp[V.size()-1]) printf("%d ", it); }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:36:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<V.size(); i++)
               ~^~~~~~~~~
toy.cpp:46:38: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", dp[V.size()-1].size());
                 ~~~~~~~~~~~~~~~~~~~~~^
toy.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &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...