Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int st[27], n, m, x, divs[27];
- ofstream fout("sir.out");
- void tipar(int k)
- {
- for (int i = 1; i <= k; i++)
- fout << divs[st[i]] << ' ';
- fout << endl;
- }
- int solutie(int k)
- {
- return k == m;
- }
- void bktr()
- {
- int k = 1;
- st[k] = 0;
- while (k)
- {
- if (st[k] < n)
- {
- st[k]++;
- if (solutie(k))
- tipar(k);
- else
- {
- k++;
- st[k] = st[k - 1];
- }
- }
- else
- k--;
- }
- }
- void getDivs() {
- for (int d = 1; d <= x / 2; d++)
- if (x % d == 0)
- divs[++n] = d;
- divs[++n] = x;
- }
- int main ()
- {
- cin >> m >> x;
- getDivs();
- bktr();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement