打明天的卡，让明天无卡可打

``````package month_training;

public class 裁纸刀 {
public static void main(String[] args) {
int count = 4;
System.out.print(4+21+22*19);
}

}
``````

hhhhh，写题解果然是有用的，我说为什么一个样例一直过不去（真的是这个问题hhhh.....大意了）

``````package month_training;

import java.math.BigInteger;
import java.util.Scanner;

public class 刷题 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
BigInteger n = sc.nextBigInteger();
BigInteger week = a.multiply(BigInteger.valueOf(5)) ;
week = week.add(b.multiply(BigInteger.valueOf(2)));
BigInteger tmp = n;
BigInteger count = BigInteger.valueOf(0);
count= tmp.divide(week);
count = count.subtract(count.remainder(BigInteger.valueOf(1)));
tmp = tmp.subtract(week.multiply(count));

if(tmp.compareTo(BigInteger.valueOf(0))==0) {
count = count.multiply(BigInteger.valueOf(7));
System.out.println(count);
return;
}
for(int i = 1 ;i<=5;i++) {
tmp = tmp.subtract(a);
if(tmp.compareTo(BigInteger.valueOf(0)) != 1) {
count = count.multiply(BigInteger.valueOf(7));
count = count.add(BigInteger.valueOf(i));
System.out.println(count);
return;
}
}
tmp = tmp.subtract(b);
if(tmp.compareTo(BigInteger.valueOf(0))!=1) {
count = count.multiply(BigInteger.valueOf(7));
count = count.add(BigInteger.valueOf(6));
System.out.println(count);
return;
}
count = count.add(BigInteger.valueOf(1));
count = count.multiply(BigInteger.valueOf(7));
System.out.println(count);
}

}
``````

``````package month_training;

import java.util.Scanner;

public class 修建灌木 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n =sc.nextInt();
int[] ans = new int[n+1];
if(n%2 == 0) {
for(int i = 1;i<=n/2;i++) {
ans[i] = 2*(n-i);
ans[n+1-i] = ans[i];
}
}
if(n%2==1) {
for(int i = 1; i<=(n-1)/2;i++) {
ans[i] = 2*(n-i);
ans[n+1-i] = ans[i];
}
ans[(n+1)/2] = n-1;
}
for(int i =1 ;i<=n;i++) {
System.out.println(ans[i]);
}
}

}``````

``````package month_training;
import java.io.*;
public class k倍数区间 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args)throws IOException {
String[] s = br.readLine().split(" ");
long n = Integer.parseInt(s[0]);
long k = Integer.parseInt(s[1]);
long[] ans = new long[(int) (n+3)];
long[] qzh = new long[(int) (n+3)];
long[] div = new long[(int) (n+3)];
for(int i = 1;i<=n;i++) {
ans[i] = Integer.parseInt(br.readLine());
qzh[i] = qzh[i-1] + ans[i];
}
div[0] = 1;
int an = 0;
for(int i = 1;i<=n;i++) {
an += div[(int) (qzh[i]%k)];
div[(int) (qzh[i]%k)]++;
}
System.out.print(an);
}

}
``````

(补于3.13早上七点三十五

``````package month_training;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class 树状数组 {
static HashMap<Integer, List<Integer>> map1 = new HashMap<>();
static HashMap<Integer, List<Integer>> map2 = new HashMap<>();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] qzh=new int[n+3];
for(int i =1 ;i<=n;i++) {
qzh[i] =sc.nextInt();
qzh[i] = qzh[i]+qzh[i-1];
}
for(int i=0;i<=n;i++) {
add(true,qzh[i],qzh[i]%k);
add(false,i,qzh[i]%k);
}
int ans =0;
TreeArray t =new TreeArray(n+5);
List<Integer> q = new ArrayList<>(map1.keySet());
for(Integer qq:q) {
List<Integer> tmp = map1.get(qq);
//Collections.sort(tmp);

if(qq>=0) {
for(int i = 0;i<tmp.size();i++) {
for(int j = i+1;j<tmp.size();j++) {
if(tmp.get(j)>=tmp.get(i)) {
ans += t.getsum(j-1+1);
t.update(j-1+1, 1);
}
}
}
if(map1.containsKey(qq-k)) {
List<Integer> tmp3 = map2.get(qq);
List<Integer> tmp4 = map2.get(qq-k);
for(int i = 0;i<tmp.size();i++) {
for(int j = i+1;j<tmp4.size();j++) {
if(tmp4.get(j)>tmp3.get(i)) {
ans+=t.getsum(j-1+1);
t.update(j-1+1, 1);
}

}

}
}

}
else {
for(int i = 0;i<tmp.size();i++) {
for(int j = i+1;j<tmp.size();j++) {
if(tmp.get(j)>=tmp.get(i)) {
ans += t.getsum(j-1+1);
t.update(j-1+1, 1);
}
}
}

}

}
}
static void add(boolean a,int y,int x) {
if(a) {
if(!map1.containsKey(x)) {
map1.put(x, new ArrayList<>());
}
map1.get(x).add(y);
}
if(!a) {
if(!map2.containsKey(x)) {
map2.put(x, new ArrayList<>());
}
map2.get(x).add(y);

}
}
static class TreeArray {
int[] A;
int[] C;
int n;
/*public  TreeArray(int[] A) {
this.A = new int[A.length];
n= A.length;
C = new int[n+1];
for(int i=0;i<=A.length;i++) {
update(i,A[i-1]);
}
}*/
public  TreeArray(int n) {
this.A = new int[n];
C = new int[n+1];
for(int i=0;i<=A.length;i++) {
update(i,A[i-1]);
}
}
public int lowbit(int x) {
return x&(-x);
}

public void update(int i,int val) {
int deta = val - A[i-1];
A[i-1] = val;
for(int pos = i;pos<=n;pos+=lowbit(pos)) {
C[pos] +=deta;
}
}
public int getsum(int pos) {
int sum=0;
for(int i=pos;i>=1;i-=lowbit(i)) {
sum = sum+C[i];
}
return sum;
}
public int sumRange(int start,int end) {
if(start<1 || start >n ||end <1||end>n) {
return -1;
}
else return getsum(end)-getsum(start-1);
}
}

}

``````

...全文
55 回复 打赏 收藏 转发到动态 举报

50,780

• 近7日
• 近30日
• 至今

刷题！