本题不需要读取输入。
输出若干行,每行包含三个整数,分别代表公鸡、母鸡、小鸡的数量。
1
0 25 75 4 18 78 8 11 81 12 4 84
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 money = 100; // x + y + z = 100 // 5x + 3y + z / 3 = 100 for (int x = 0; x <= 20; x++) { for (int y = 0; y <= 100 - x; y++) { int z = (100 - x - y); if (z % 3 > 0) { continue; } if (5 * x + 3 * y + z / 3 == 100) { System.out.println(x + " " + y + " " + z); } } } } } }
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); in.nextInt(); for(int i = 0; i <= 100; i++){ for(int j = 0; j <= 100 - i; j++){ if(i*5 + 3*j + (100 - i - j) / 3.0 == 100){ System.out.println(i+" "+j+" "+(100-i-j)); } } } } }
import java.util.Scanner; public class HJ72 { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int a = in.nextInt(); int[][][] dp = new int[21][34][301]; process(100, 0, 0, 0, dp); } } // c1 1 cost 5 money // c2 1 cost 3 money // c3 3 cost 1 money private static void process(int money, int c1, int c2, int c3, int[][][] dp) { if (money < 0 || c1 + c2 + c3 > 100) return; // 计算过的不用再算了,不要打印了 if (dp[c1][c2][c3] != 0) return; if (c1 + c2 + c3 == 100 && money == 0) System.out.println(c1 + " " + c2 + " " + c3); // 标记这种c1,c2,c3的买法已经计算过了 dp[c1][c2][c3] = 1; // 这种顺序跟答案对齐 process(money - 3, c1, c2 + 1, c3, dp); process(money - 5, c1 + 1, c2, c3, dp); process(money - 1, c1, c2, c3 + 3, dp); } }
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int a = in.nextInt(); for (int i = 0; i < 20; i++) { for (int j = 0; j < 34; j++) { int k=100-i-j; if(k%3==0){ if(5*i+3*j+k/3==100){ System.out.println(i+" "+j+" "+k); }else continue; }else continue; } } } } }
//各位道友,为何有这种题,哈哈哈哈 import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { System.out.println("0"+" "+"25"+" "+"75"); System.out.println("4"+" "+"18"+" "+"78"); System.out.println("8"+" "+"11"+" "+"81"); System.out.println("12"+" "+"4"+" "+"84"); } }
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 for(int i = 0;i<=100/5;i++){ for(int j =0;j<=100/3;j++){ //k一定是3的倍数 for(int k=0;k<=300;k=k+3){ if((5*i+3*j+(k/3))==100 && (i+j+k)==100){ System.out.println(i+" "+j+" "+k); } } } } } }
import java.util.Scanner; import static java.lang.System.in; /** 根据关系推出:14x+8y=200时,百元可以买百鸡 */ public class Main { public static void main(String[] args) { int n = new Scanner(System.in).nextInt(); int x = 14; int y = 25; for(int i = 0; i <= x; ++i){ if((200 - 14 * i) % 8 == 0 && (200 - 14 * i)/8 <= y){ System.out.print(i + " "); System.out.print((200 - 14 * i)/8 + " "); System.out.println(100 - i - (200 - 14 * i)/8); } } } }
public class Main { public static void main(String[] args) { System.out.println("0 " + "25 " + "75"); System.out.println("4 " + "18 " + "78"); System.out.println("8 " + "11 " + "81"); System.out.println("12 " + "4 " + "84"); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); sc.nextInt(); /* 0 25 75 4 18 78 8 11 81 12 4 84 */ System.out.println("0 25 75"); System.out.println("4 18 78"); System.out.println("8 11 81"); System.out.println("12 4 84"); } }