Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream in("fractii2.in");
- ofstream out("fractii2.out");
- const int dim = 2005;
- int cerinta,valori[dim];
- int n,cnt;
- void Afisare()
- {
- float ofo = 0.0;
- for (int i=1; i<=n; i++)
- {
- /// cout << valori[i] << " ";
- ofo += ((1.0)/(1<<valori[i]));
- }
- if (ofo == 1.0)
- {
- cnt++;
- }
- }
- void Back(int top)
- {
- if (top == n+1)
- {
- Afisare();
- }
- else
- {
- for (int i=1; i<=16; i++)
- {
- if (i >= valori[top-1])
- {
- valori[top] = i;
- Back(top+1);
- }
- }
- }
- }
- int main()
- {
- in >> cerinta;
- in >> n;
- if (cerinta == 1)
- {
- for (int i=1; i<n; i++)
- {
- out << i << " ";
- }
- out << n-1;
- }
- else
- {
- cnt = 0;
- Back(1);
- cout << cnt;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement