Submission #70966

#TimeUsernameProblemLanguageResultExecution timeMemory
70966MatheusLealVToys (CEOI18_toy)C++17
100 / 100
2260 ms33720 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> lista; int solve(int n, int sum, int m) { if(n == 1) lista.push_back(sum); for(int i = 1; i * i <= n; i++) { if( n % i != 0) continue; if(i <= m and i > 1) solve(n/i, sum + i - 1, i); int j = n/i; if(j <= m and j > 1) solve(n/j, sum + j - 1, j); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n; solve(n, 0, n); sort(lista.begin(), lista.end()); lista.erase(unique(lista.begin(), lista.end()), lista.end()); cout<<lista.size()<<"\n"; for(int i = 0; i < lista.size(); i++) cout<<lista[i]<<" "; cout<<"\n"; }

Compilation message (stderr)

toy.cpp: In function 'int solve(int, int, int)':
toy.cpp:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
toy.cpp: In function 'int main()':
toy.cpp:39:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < lista.size(); i++) cout<<lista[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...