Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Write a function that finds the number of solutions of the system in natural numbers (ℕ∪{0}):
  2. x_1+x_2+x_3+x_4+x_5=100; x_1<10; 10≤x_2<30; x_4>20; x_5<30.
  3.  
  4. #include <iostream>
  5. #include <cmath>
  6. int main()
  7. {
  8. size_t n;
  9. std::cin >> n;
  10. size_t count(0);
  11.  
  12. for (size_t i = 0; i < 10; i++)
  13. for (size_t j = 10; j < 30; j++)
  14. for (size_t k = 10; k < 30; k++)
  15. for (size_t l = 21; l < n; l++)
  16. for (size_t m = 0; m < 30; m++)
  17. if (i + j + k + l + m == n)
  18. count++;
  19. std::cout << count << std::endl;
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement