Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream in("fractii2.in");
  7. ofstream out("fractii2.out");
  8.  
  9. const int dim = 2005;
  10.  
  11. int cerinta,valori[dim];
  12. int n,cnt;
  13.  
  14. void Afisare()
  15. {
  16. float ofo = 0.0;
  17. for (int i=1; i<=n; i++)
  18. {
  19. /// cout << valori[i] << " ";
  20. ofo += ((1.0)/(1<<valori[i]));
  21. }
  22. if (ofo == 1.0)
  23. {
  24. cnt++;
  25. }
  26. }
  27.  
  28. void Back(int top)
  29. {
  30. if (top == n+1)
  31. {
  32. Afisare();
  33. }
  34. else
  35. {
  36. for (int i=1; i<=16; i++)
  37. {
  38. if (i >= valori[top-1])
  39. {
  40. valori[top] = i;
  41. Back(top+1);
  42. }
  43. }
  44. }
  45. }
  46.  
  47. int main()
  48. {
  49. in >> cerinta;
  50. in >> n;
  51.  
  52. if (cerinta == 1)
  53. {
  54. for (int i=1; i<n; i++)
  55. {
  56. out << i << " ";
  57. }
  58. out << n-1;
  59. }
  60. else
  61. {
  62. cnt = 0;
  63. Back(1);
  64. cout << cnt;
  65. }
  66.  
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement