Submission #123133

#TimeUsernameProblemLanguageResultExecution timeMemory
123133davitmargToys (CEOI18_toy)C++17
19 / 100
28 ms396 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 n; vector<int> a; set<int> s; void dfs(int p,int sum,int d) { //cout<<sum<<" : "<<d<<endl; if(p==a.size()) { s.insert(sum+d-1); return; } dfs(p+1,sum+d-1,a[p]); dfs(p+1,sum,d*a[p]); } int main() { cin>>n; for(int i=2;i*i<=n;i++) { if(n%i) continue; while(n%i==0) { a.PB(i); n/=i; } } if(n>1) a.PB(n); sort(all(a)); random_shuffle(all(a)); int op=0; do { dfs(0,0,1); op+=n; if(op>10000000) break; }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)':
toy.cpp:31: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...