public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] res = new int[n]; for (int j = 0; j < n; j++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int q = sc.nextInt(); boolean[] dp = new boolean[q + 1]; dp[0] = true; if (q > a) dp[a] = true; for (int i = 1; i <= q; i++) { if (i > b) { if (i % c == 0) dp[i] = dp[i - b] || dp[i / c]; else dp[i] = dp[i - b]; } } if (dp[q]) res[j] = 1; else res[j] = 0; } for (int i = 0; i < n; i++) { System.out.println(res[i]); } } } 有没有大佬帮忙看一下哪里出问题了 样例在本地跑过了 提交0%😂
点赞 1
牛客网
牛客企业服务