首页 > 拼多多7.25笔试第三题,样例只能本地过,大佬能看看吗
头像
牛客58488149号
发布于 2021-07-25 23:03
+ 关注

拼多多7.25笔试第三题,样例只能本地过,大佬能看看吗

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) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

热门推荐