Submission #748650

#TimeUsernameProblemLanguageResultExecution timeMemory
748650mariowongToys (CEOI18_toy)C++14
100 / 100
765 ms20716 KiB
#include <bits/stdc++.h> using namespace std; int n; vector <int> fac; unordered_map <int,vector<int> > m; unordered_map <int,int> now; int main(){ ios::sync_with_stdio(false); cin >> n; m.reserve(1000000); for (int i=1;i*i<=n;i++){ if (n%i == 0){ if (n/i != i) fac.push_back(n/i); fac.push_back(i); } } sort(fac.begin(),fac.end()); for (int i=0;i<fac.size();i++){ now.clear(); now[fac[i]-1]=true; m[fac[i]].push_back(fac[i]-1); for (int j=0;j<i;j++){ if (fac[i]%fac[j] == 0){ for (int k=0;k<m[fac[j]].size();k++){ if (!now[m[fac[j]][k]+fac[i]/fac[j]-1]){ now[m[fac[j]][k]+fac[i]/fac[j]-1]=true; m[fac[i]].push_back(m[fac[j]][k]+fac[i]/fac[j]-1); } } } } } sort(m[n].begin(),m[n].end()); cout << (int)m[n].size() << "\n"; for (int i=0;i<m[n].size();i++){ cout << m[n][i] << " "; } cout << "\n"; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i=0;i<fac.size();i++){
      |               ~^~~~~~~~~~~
toy.cpp:26:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int k=0;k<m[fac[j]].size();k++){
      |                  ~^~~~~~~~~~~~~~~~~
toy.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for (int i=0;i<m[n].size();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...