daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin ("sumbdiv.in");
  4. ofstream fout ("sumbdiv.out");
  5. int m , x , d[105] , n , st[7];
  6. void Back(int top)
  7. {
  8.     if(top == (m + 1))
  9.     {
  10.         for(int i = 1 ; i <= m ; i++)
  11.             fout << d[st[i]] << " ";
  12.         fout << "\n";
  13.     }
  14.     else for(int i = 1 + st[top - 1] ; i <= n ; i++)
  15.     {
  16.         st[top] = i;
  17.         Back(top + 1);
  18.     }
  19. }
  20. int main()
  21. {
  22.     fin >> x >> m;
  23.     cout << "-1\n";
  24.     for(int i = 1 ; i  <= x  ; i++)
  25.         if(x % i == 0)
  26.             d[++n] = i;
  27.     sort(d + 1 , d + n + 1);
  28.     Back(1);
  29.     fin.close();
  30.     fout.close();
  31.     return 0;
  32. }
RAW Paste Data
Top