Describes the total number of chickens and rabbits known to be n and the total number of legs m. Enter n and m, output the number of chickens and rabbits in turn, and if no solution, output "no answer" (no quotation marks).
-
- Input
-
The
- first line enters a data A, representing the next few sets of data, in the next (a<10)
in line A, each row has an N and M. (0<m,n<100)
-
- Output
-
- output the number of chicken rabbits, or no answer
-
- Sample input
-
-
214 3210 16
-
- Sample output
-
2No Answer
1 Importjava.util.Arrays;2 ImportJava.util.Scanner;3 4 Public classMain {5 Public Static voidMain (string[] args) {6Scanner scanner=NewScanner (system.in);7 intT;8 intK;9 intN;Ten intm; One At=scanner.nextint (); - for(k=0;k<t;k++){ -n=scanner.nextint (); them=scanner.nextint (); - - if(M>=2*n && (m-2*n)%2==0 && 4*n>=m && (4*n-m)%2==0) -System.out.println ((4*n-m)/2+ "" + (M-2*n)/2); + - Else +System.out.println ("No answer"); A } at } -}
Chicken and rabbit cage