25 篇文章 1 订阅

# 裁纸刀

## 参考代码

import java.io.*;
import java.util.*;
public class Main {
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

public static void main(String[] args) throws Exception {

out.println(4 + (20 - 1) + (21 * 20));

out.flush();
in.close();
}
}


# 刷题统计

## 参考代码

import java.io.*;
import java.util.*;
public class Main {
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

public static void main(String[] args) throws Exception {

long a = Long.parseLong(s[0]), b = Long.parseLong(s[1]), p = Long.parseLong(s[2]);
// 一周的刷题数量
long weekCnt = a * 5 + b * 2;
// 刷题的周数
long weekSum = p / weekCnt;
// 当前刷题天数
long ans = weekSum * 7;
// 剩余的题目
p %= weekCnt;
// 当前是星期一
int cur = 1;
while (p > 0) {
p -= cur <= 5? a: b;
cur++;
ans++;
}
out.println(ans);

out.flush();
in.close();
}
}


# 修剪灌木

## 参考代码

import java.io.*;
public class Main {
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

public static void main(String[] args) throws Exception {

int mid = n / 2;
for (int i = 1; i <= mid; i++) {
out.println((n - i) * 2);
}

if ((n & 1) == 1) out.println((n - mid - 1) * 2);

for (int i = mid; i >= 1; i--) {
out.println((n - i) * 2);
}
out.flush();
in.close();
}
}


# k倍区间

k倍区间

2588. 统计美丽子数组数目

## 参考代码

import java.io.*;
import java.util.*;
public class Main {
static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

static int N = (int)1e5 + 10, n, k;
static int[] a = new int[N], pre = new int[N];
static Map<Integer, Integer> map = new HashMap<>();

public static void main(String[] args) throws Exception {
n = Integer.parseInt(s[0]);
k = Integer.parseInt(s[1]);
for (int i = 1; i <= n; i++) {
pre[i] = (pre[i - 1] + a[i]) % k;
}
long ans = 0L;
for (int i = 0; i <= n; i++) {
ans += map.getOrDefault(pre[i], 0);
map.put(pre[i], map.getOrDefault(pre[i], 0) + 1);
}

out.println(ans);

out.flush();
in.close();
}
}

• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 打赏
• 0
评论
07-28
01-13 151
11-05
04-02
05-20
02-15
04-01
04-01

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

⠀One0ne

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。