Submission #385382

#TimeUsernameProblemLanguageResultExecution timeMemory
385382igziToys (CEOI18_toy)C++17
79 / 100
5104 ms70236 KiB
#include <bits/stdc++.h> using namespace std; set<pair<int,int>> dp; vector<pair<int,int>> v; vector<int> sol; int n; void solve(int bm , int cnt , int mult , int pos , int x){ if(pos == v.size()){ if(mult < x || mult == 1){ return ; } if(bm == 1){ sol.push_back(cnt+mult-1); return ; } solve(bm,cnt+mult-1,1,0,mult); return ; } if(pos == 0 && mult == 1){ if(dp.find({bm,cnt}) != dp.end()){ return ; } dp.insert({bm,cnt}); } solve(bm,cnt,mult,pos+1,x); if(bm%v[pos].first == 0){ solve(bm/v[pos].first,cnt,mult*v[pos].first,pos,x); } } int main(){ cin >> n; int nn = n; if(n == 1){ cout << 1 << endl << 0 << endl; return 0; } for(int i = 2 ; i*i <= n ; i += 1){ if(n%i == 0){ int cnt = 0; while(n%i == 0){ n /= i; cnt += 1; } v.push_back({i,cnt}); } } if(n > 1){ v.push_back({n,1}); } solve(nn,0,1,0,1); sort(sol.begin(),sol.end()); sol.erase(unique(sol.begin(),sol.end()),sol.end()); cout << sol.size() << endl; for(int i : sol){ cout << i << " "; }cout << endl; }

Compilation message (stderr)

toy.cpp: In function 'void solve(int, int, int, int, int)':
toy.cpp:9:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     if(pos == v.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...