import java.util.Scanner; 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]); } } } 拼多多7.25笔试第三题,样例本地能过提交上去为0%,大佬能看看吗
全部评论
(3) 回帖