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

ThoU4 2023-03-13 09:53:38

裁纸刀

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);

    }
}

 

 

...全文
20 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,782

社区成员

发帖
与我相关
我的任务
社区描述
和众多高校算法内卷分子,一起学习和交流算法那。浓郁的算法交流氛围,拒绝躺平,有效内卷。加入我们,私信我拉你入核心内卷群。
算法数据结构leetcode 个人社区
社区管理员
  • 执 梗
  • Dream-Y.ocean
  • ღCauchyོꦿ࿐
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

 刷题!

试试用AI创作助手写篇文章吧