第十四届蓝桥杯三月真题刷题训练——第 10 天

ThoU4 ThoU4 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

裁纸刀

public class Main {
    public static void main(String[] args) {
        System.out.println(4 + 19 + (21 * 20));
    }
}

 刷题统计

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        long a = scan.nextLong();
        long b = scan.nextLong();
        long n = scan.nextLong();
        long week = n / (a * 5 + b * 2);
        long res = week * 7;
        n %= (a * 5 + b * 2);
        if(n > a * 5){
          res += 5;
          n -= a * 5;
          res += ((n - 1) / b) + 1;
        }else {
          res += ((n - 1) / a) + 1;
        }
        System.out.println(res);
        scan.close();
    }
}

 修剪灌木

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int max;
        for (int i=1;i<=n ;i++) {
            max = Math.max(i-1, n-i);
            System.out.println(max * 2);
        }
        scan.close();
    }
}

 k倍区间

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] arr = new long[n];
        long[] yu = new long[k];
        long sum = 0;
        long count = 0;
        for (int i = 0; i <n ; i++) {
            arr[i] = sc.nextInt();
            count += arr[i];
            arr[i] = count;
            yu[ (int) (arr[i] % k) ]++;
        }
        sum += yu[0];
        for (int i = 0; i < k ; i++) {
          sum += yu[i] * (yu[i] - 1) /2;
        }
        System.out.println(sum);

    }
}

 

 

...全文
评论
收藏 已收藏
分享
返回顶部
ThoU4
高校算法学习社区 51,730 成员 6,062 内容