SHARE
TWEET

vasyyy

a guest Oct 23rd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream in("suma35.in");
  5. ofstream out("suma35.out");
  6. long long n,k, st[101],v[101],ap[101],x;
  7. int valid(int k){
  8.     if(k==1&&v[st[k]]==0) return 0;
  9.     return 1;
  10. }
  11. int sol(int k){
  12.     if(k==n) return 1;
  13.     return 0;
  14. }
  15. void tipar (int k){
  16.     for(int i=1;i<=k;i++)
  17.         cout<<v[st[i]];
  18.     cout<<'\n';
  19. }
  20. void backt(int k){
  21. for(int i=1;i<=n;i++){
  22.         st[k]=i;
  23.     if(ap[st[k]]==0&&valid(k)){
  24.         ap[st[k]]=1;
  25.         if(k==n) tipar(k);
  26.         else backt(k+1);
  27.         ap[st[k]]=0;
  28.     }
  29. }
  30. }
  31. int main()
  32. {
  33.     cin>>x;
  34.     while(x>0){
  35.         v[++n]=x%10;
  36.         x=x/10;
  37.     }
  38.     sort(v+1,v+n+1);
  39.     backt(1);
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top