题解 | #百鸡问题#两重暴力for循环枚举就行
百鸡问题
https://www.nowcoder.com/practice/01d161052db64c249a47fc723b4fd5db
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int x = 0; x <= 100; x++) { for (int y = 0; y <= 100 - x; y++) { int k = 100 - x - y; if (x * 15 + y * 9 + k <= n * 3) System.out.println("x=" + x + ",y=" + y + ",z=" + k); } } } }