Submission #1051438

#TimeUsernameProblemLanguageResultExecution timeMemory
1051438antonToys (CEOI18_toy)C++17
19 / 100
99 ms262144 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;){ if(n%i == 0){ res.push_back(i); n/=i; } else{ 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); } } vector<vector<int>> assignements(int n){ vector<vector<int>> res; vector<int> cur = vector<int>(n, 0); recur(0, n, res, cur); return res; } signed main(){ cin>>N; auto factors = factorize(N); set<int> possib; int K = factors.size(); for(auto assign: assignements(K)){ vector<int> prod(K, 1); for(int i = 0; i<K; i++){ prod[assign[i]] =(prod[assign[i]]* factors[i]); } int s= 0; for(auto e: prod){ s+=e-1; } possib.insert(s); } 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:22: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]
   22 |     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...