Submission #123092

#TimeUsernameProblemLanguageResultExecution timeMemory
123092davitmargToys (CEOI18_toy)C++17
19 / 100
4 ms380 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <iomanip> #include <stack> #include <cassert> #include <iterator> #include <bitset> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(),v.end() using namespace std; int binpow (int a, int n) { int res = 1; while (n) if (n & 1) { res *= a; --n; } else { a *= a; n >>= 1; } return res; } int n; vector<pair<int,int>> a; set<int> s; void dfs(int p,int sum,int d,int cnt) { //cout<<sum<<" : "<<d<<endl; if(p==a.size()) { s.insert(sum+d-1); return; } if(cnt==0) cnt=a[p].second; dfs(p+(cnt-1==0),sum+d-1,a[p].first,cnt-1); dfs(p+(cnt-1==0),sum,d*a[p].first,cnt-1); } int main() { cin>>n; for(int i=2;i*i<=n;i++) { if(n%i) continue; a.PB(MP(i,0)); while(n%i==0) { a.back().second++; n/=i; } } if(n>1) a.PB(MP(n,1)); sort(all(a)); do { dfs(0,0,1,0); }while(next_permutation(all(a))); cout<<s.size()<<endl; for(auto it=s.begin();it!=s.end();++it) printf("%d ",(*it)); cout<<endl; return 0; } /* */

Compilation message (stderr)

toy.cpp: In function 'void dfs(int, int, int, int)':
toy.cpp:45:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(p==a.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...