Submission #963428

#TimeUsernameProblemLanguageResultExecution timeMemory
963428pccToys (CEOI18_toy)C++17
100 / 100
3095 ms90232 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 2022; ll N; vector<ll> facs; set<ll> dp[mxn]; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N; if(N == 1){ cout<<"1\n0\n"; return 0; } for(int i = 1;i*i<=N;i++){ if(N%i == 0){ facs.push_back(i); if(i*i != N)facs.push_back(N/i); } } sort(facs.begin(),facs.end()); dp[0].insert(0); for(int i = 0;i<facs.size();i++){ for(int j = i+1;j<facs.size();j++){ if(facs[j]%facs[i] == 0){ int r = facs[j]/facs[i]; for(auto &k:dp[i]){ dp[j].insert(k+(r-1)); } } } } auto ans = dp[facs.size()-1]; cout<<ans.size()<<'\n'; for(auto &i:ans)cout<<i<<' ';cout<<'\n'; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i = 0;i<facs.size();i++){
      |                ~^~~~~~~~~~~~
toy.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int j = i+1;j<facs.size();j++){
      |                   ~^~~~~~~~~~~~
toy.cpp:46:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |  for(auto &i:ans)cout<<i<<' ';cout<<'\n';
      |  ^~~
toy.cpp:46:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |  for(auto &i:ans)cout<<i<<' ';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...