“Chicken-Rabbit Math Problem (雞兔同籠)” is an ancient Chinese math problem. Known the total number of heads and feet, we may tell the number of chickens and the number of rabbits respectively by solving the problem.
To solve this problem by programming, we may use brute-force algorithm (暴力演算法) to find out the answer directly. Read and understand the code in main.cpp, function.h, and implment your brute-force algorithm ChickenNRabbitProblem::Solve() in function.cpp.
Hint:
The structure is look like the figure below.
Only need to implement ChickenNRabbitProblem::Solve(). Use ChickenNRabbit-Problem:: CheckSolution (), ChickenNRabbitProblem::PrintSolution() and functions in class ChickenCounter, RabbitCounter for help.
head_num feet_num
note: head_num and feet_num are integers, represent as the target total number of head and feet respectively.
Output should follow below format:
Chicken: chicken_num, Rabbit: rabbit_num
note: chicken_num and rabbit_num represent as the answer of the Chicken-Rabbit Problem. If there is no solutions, print “no solutions” instead.
For example:
Input:
2 6
Output:
Chicken: 1, Rabbit: 1
Input:
2 5
Output:
no solutions