Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a function that finds the number of solutions of the system in natural numbers (ℕ∪{0}):
- x_1+x_2+x_3+x_4+x_5=100; x_1<10; 10≤x_2<30; x_4>20; x_5<30.
- #include <iostream>
- #include <cmath>
- int main()
- {
- size_t n;
- std::cin >> n;
- size_t count(0);
- for (size_t i = 0; i < 10; i++)
- for (size_t j = 10; j < 30; j++)
- for (size_t k = 10; k < 30; k++)
- for (size_t l = 21; l < n; l++)
- for (size_t m = 0; m < 30; m++)
- if (i + j + k + l + m == n)
- count++;
- std::cout << count << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement