Advertisement
a53

perm_rep2

a53
Jan 1st, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. #include <set>
  5. using namespace std;
  6.  
  7. int main(void)
  8. {
  9. int n,r;
  10. vector<int> v;
  11. set<int> s;
  12. cin>>n;
  13. while(n)
  14. v.push_back(n%10),n/=10;
  15. sort(v.begin(),v.end());
  16. do
  17. {
  18. r=0;
  19. for(auto i:v)
  20. r*=10,r+=i;
  21. if(s.find(r) == s.end())
  22. cout<<r<<'\n',s.insert(r);
  23. } while(next_permutation(v.begin(),v.end()));
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement