每组测试数据占1行,每行一个正整数a (a < 32768)
输出包含n行,每行对应一个输入,包含两个正整数,第一个是最少的动物数,第二个是最多的动物数,两个正整数用一个空格分开 如果没有满足要求的答案,则输出两个0。
2 3 20
1 1 0 0 5 10
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int a = in.nextInt(); //脚总数 int min,max; //最少,最大动物数 int temp; if(a%2!=0) System.out.println("0 0"); else{ //min min = a / 4; temp = (a - (min * 4))/ 2; min+=temp; //max max = a / 2; System.out.println(min + " " + max); } } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ int a = scanner.nextInt(); if (a%2!=0||a<=1)System.out.println("0 0"); else { int min = a/4+(a%4)/2; int max = a/2; System.out.println(min+" "+max); } } } }