Submission #1051489

#TimeUsernameProblemLanguageResultExecution timeMemory
1051489antonToys (CEOI18_toy)C++17
59 / 100
5063 ms852 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int N; vector<int> factorize(int n){ vector<int> res; for(int i = 2; i*i<=n;i++){ if(n%i == 0){ res.push_back(i); if(i*i!=n){ res.push_back(n/i); } } } res.push_back(n); return res; } void recur(int pos, int max_c, vector<vector<int>>& res, vector<int>& cur){ if(pos == cur.size()){ res.push_back(cur); return; } for(int i = 0; i<max_c; i++){ cur[pos] = i; recur(pos+1, max_c, res, cur); } } set<int> sums(int n){ set<int> res; if(n==1){ res.insert(0); return res; } auto factors = factorize(n); for(auto e: factors){ auto ch_s = sums(n/e); for(auto ee: ch_s){ res.insert(ee+e-1); } } return res; } signed main(){ cin>>N; auto possib = sums(N); cout<<possib.size()<<endl; for(auto e: possib){ cout<<e<<" "; } cout<<endl; }

Compilation message (stderr)

toy.cpp: In function 'void recur(long long int, long long int, std::vector<std::vector<long long int> >&, std::vector<long long int>&)':
toy.cpp:21:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if(pos == cur.size()){
      |        ~~~~^~~~~~~~~~~~~
#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...