Advertisement
DaniDori

Untitled

Feb 11th, 2023
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include<algorithm>
  3. #include<time.h>
  4. using namespace std;
  5. void rec(int x, int y, int z, int w, int& count, int sum=0,int chet=0) {
  6. if (sum == w) {
  7. count ++;
  8. return;
  9. }
  10. if (sum > w) {
  11. return;
  12. }
  13. if (sum + x <= w and chet <=1) {
  14. rec(x, y, z, w, count, sum + x,1);
  15. }
  16. if (sum + y <= w and chet <=2) {
  17. rec(x, y, z,w, count, sum + y,2);
  18. }
  19. if (sum + z) {
  20. rec(x, y, z, w, count, sum + z,3);
  21. }
  22. }
  23. int main()
  24. {
  25. int x, y, z, w, count = 0;
  26. cin >> x >> y >> z >> w;
  27. rec(x, y, z, w, count);
  28. cout << count;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement