Ver código fonte

first commit

yang yi 3 meses atrás
commit
1e3014f410
73 arquivos alterados com 4337 adições e 0 exclusões
  1. 149 0
      src/CCSP/A2023/t1/Main.java
  2. 208 0
      src/CCSP/A2023/t2/Main.java
  3. 45 0
      src/CSP/A201312/A1/Main.java
  4. 96 0
      src/CSP/A201612/A2/Main.java
  5. 56 0
      src/CSP/A202203/A1/Main.java
  6. 67 0
      src/CSP/A202203/A2/Main.java
  7. 44 0
      src/CSP/A202206/A1/Main.java
  8. 124 0
      src/CSP/A202206/A2/Main.java
  9. 49 0
      src/CSP/A202209/A1/Main.java
  10. 38 0
      src/CSP/A202209/A2/Main.java
  11. 33 0
      src/CSP/A202212/A1/Main.java
  12. 108 0
      src/CSP/A202212/A2/Main.java
  13. 135 0
      src/CSP/A202212/A3/Main.java
  14. 83 0
      src/CSP/A202303/A1/Main.java
  15. 65 0
      src/CSP/A202303/A2/Main.java
  16. 248 0
      src/CSP/A202303/A3/Main.java
  17. 45 0
      src/CSP/A202305/A1/Main.java
  18. 108 0
      src/CSP/A202305/A2/Main.java
  19. 192 0
      src/CSP/A202305/A3/Main.java
  20. 17 0
      src/CSP/StackSizeTest.java
  21. 55 0
      src/CSP/temp/A1/Main.java
  22. 48 0
      src/CSP/temp/A2/Main.java
  23. 160 0
      src/CSP/temp/A3/Main.java
  24. 106 0
      src/CSP/temp/A4/Main.java
  25. 71 0
      src/CSP/temp/A5/Main.java
  26. 107 0
      src/Codec.java
  27. 137 0
      src/Exercise.java
  28. 14 0
      src/ListNode.java
  29. 12 0
      src/Main.java
  30. 27 0
      src/Node.java
  31. 22 0
      src/Solution.java
  32. 11 0
      src/StackTest.java
  33. 25 0
      src/TreeNode.java
  34. 23 0
      src/User.java
  35. 24 0
      src/leetcode/p1342/Solution.java
  36. 21 0
      src/leetcode/p1342/SolutionTest.java
  37. 22 0
      src/leetcode/p1702/Solution.java
  38. 20 0
      src/leetcode/p2529/Solution.java
  39. 25 0
      src/leetcode/p2529/SolutionTest.java
  40. 112 0
      src/leetcode/p2892/Solution.java
  41. 49 0
      src/leetcode/p2892/SolutionTest.java
  42. 49 0
      src/leetcode/p2965/Solution.java
  43. 36 0
      src/leetcode/p2965/SolutionTest.java
  44. 74 0
      src/leetcode/p2981/Solution.java
  45. 37 0
      src/leetcode/p2981/SolutionTest.java
  46. 19 0
      src/leetcode/p740/Solution.java
  47. 28 0
      src/leetcode/p740/SolutionTest.java
  48. 21 0
      src/leetcode/p764/Solution.java
  49. 22 0
      src/leetcode/p764/SolutionTest.java
  50. 52 0
      src/luogu/t1/Main.java
  51. 61 0
      src/luogu/t2/Main.java
  52. 51 0
      src/luogu/t3/Main.java
  53. 61 0
      src/luogu/t4/Main.java
  54. 50 0
      src/luogu/t5/Main.java
  55. 35 0
      src/weekContest/A361/A1/Solution.java
  56. 23 0
      src/weekContest/A361/A2/Solution.java
  57. 30 0
      src/weekContest/A361/A3/Solution.java
  58. 56 0
      src/weekContest/A399/A1/Solution.java
  59. 24 0
      src/weekContest/A399/A1/SolutionTest.java
  60. 68 0
      src/weekContest/A399/A2/Solution.java
  61. 27 0
      src/weekContest/A399/A2/SolutionTest.java
  62. 115 0
      src/weekContest/A399/A3/Solution.java
  63. 37 0
      src/weekContest/A399/A3/SolutionTest.java
  64. 56 0
      src/weekContest/A399/A4/Solution.java
  65. 26 0
      src/weekContest/A400/A1/Solution.java
  66. 21 0
      src/weekContest/A400/A1/SolutionTest.java
  67. 38 0
      src/weekContest/A400/A2/Solution.java
  68. 46 0
      src/weekContest/A400/A2/SolutionTest.java
  69. 75 0
      src/weekContest/A400/A3/Solution.java
  70. 36 0
      src/weekContest/A400/A3/SolutionTest.java
  71. 11 0
      src/weekContest/A400/A4/Solution.java
  72. 20 0
      src/weekContest/B112/A1A2/Solution.java
  73. 31 0
      src/weekContest/B112/A3/Solution.java

+ 149 - 0
src/CCSP/A2023/t1/Main.java

@@ -0,0 +1,149 @@
+package CCSP.A2023.t1;
+import java.util.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Main
+ * @Author: 杨逸
+ * @Data:2024/10/11 9:17
+ * @Description: TODO
+ */
+public class Main {
+    public static final Scanner input = new Scanner(System.in);
+    static int n,m,p,q,min = Integer.MAX_VALUE;
+    static int[] target,giftCost;
+    static List<Element> elements = new ArrayList<>();
+    static Map<Integer,Integer> exchange = new HashMap<>();
+    static Map<Integer,Boolean> exchangeFlag = new HashMap<>();
+    static List<List<Integer>> gift = new ArrayList<>();
+    static int cost = 0;
+    static Set<Integer> currentSet = new HashSet<>();
+    public static void main(String[] args) {
+        n = input.nextInt();
+        m = input.nextInt();
+        p = input.nextInt();
+        q = input.nextInt();
+        target = new int[n];
+        giftCost = new int[q];
+        for (int i = 0; i < n; i++) {
+            target[i] = input.nextInt();
+        }
+        for (int i = 0; i < m; i++) {
+            int flag = input.nextInt();
+            Element element = new Element(i + 1);
+            if (0==flag){
+                element.cost = input.nextInt();
+            }else {
+                element.flag = true;
+                for (int j = 0; j < flag; j++) {
+                    element.child.add(input.nextInt());
+                }
+            }
+            elements.add(element);
+        }
+        for (int i = 0; i < p; i++) {
+            int a = input.nextInt();
+            int b = input.nextInt();
+            //a换b
+            exchange.put(b,a);
+            exchangeFlag.put(b,false);
+        }
+        for (int i = 0; i < q; i++) {
+            int n = input.nextInt();
+            int cost = input.nextInt();
+            ArrayList<Integer> list = new ArrayList<>();
+            giftCost[i] = cost;
+            for (int j = 0; j < n; j++) {
+                list.add(input.nextInt());
+            }
+        }
+    if (q==0){
+        //没有礼盒的算法
+        for (int v : target) {
+            if (currentSet.contains(v))continue;
+            dfs(v);
+        }
+        //valid();
+        cost = min;
+        System.out.println(cost);
+    }else {
+
+    }
+
+    }
+
+    private static void valid() {
+        for (int v : target) {
+            if (!currentSet.contains(v)) {
+                System.out.println("不合法");
+                dfs(v);
+                valid();
+                //return;
+            }
+        }
+    }
+
+    private static void dfs(int v) {
+        Element element = elements.get(v - 1);
+        boolean flag = false;
+        //交换
+        Integer value = exchange.get(element.id);
+        if (exchange.containsKey(element.id)&&currentSet.contains(value)&&(!exchangeFlag.get(element.id))){
+                currentSet.remove(value);
+                currentSet.add(element.id);
+                exchangeFlag.put(element.id,true);
+                flag = false;
+            for (int val : target) {
+                if (currentSet.contains(val))continue;
+                dfs(val);
+                flag = true;
+            }
+            exchangeFlag.put(element.id,false);
+            if (!flag&&min>cost){
+                //如果目标集都包含,则更新最小值
+                min = cost;
+            }
+            //恢复
+            currentSet.remove(element.id);
+            currentSet.add(value);
+        }
+        //买礼盒
+        if (element.flag){
+            //合成
+            List<Integer> list = element.child;
+            for (int child : list) {
+                if (currentSet.contains(child))continue;
+                dfs(child);
+            }
+            for (Integer integer : list) {
+                currentSet.remove(integer);
+            }
+        }else {
+            //直接兑换
+            cost+=element.cost;
+        }
+            currentSet.add(element.id);
+
+        flag = false;
+        for (int val : target) {
+            if (currentSet.contains(val))continue;
+            //dfs(val);
+            flag = true;
+        }
+        if (!flag&&min>cost){
+            //如果目标集都包含,则更新最小值
+            min = cost;
+        }
+    }
+}
+
+class Element{
+    public Element(int id) {
+        this.id = id;
+    }
+
+    int id;//编号
+    int cost;//成本
+    boolean flag = false;//是否需要合成
+    List<Integer> child = new ArrayList<>();//合成成本
+}

+ 208 - 0
src/CCSP/A2023/t2/Main.java

@@ -0,0 +1,208 @@
+package CCSP.A2023.t2;
+
+import java.util.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Main
+ * @Author: 杨逸
+ * @Data:2024/10/12 14:47
+ * @Description: TODO
+ */
+public class Main {
+    public static final Scanner input = new Scanner(System.in);
+    static int n,m,a,b,k,s;
+    static List<Ball> balls = new ArrayList<>();
+    static long count = 0;
+    static Set<Ball> currentBalls1 = new HashSet<>();
+    static Set<Integer> currentBallIds1 = new HashSet<>();
+    static Set<Integer> currentBallColors1 = new HashSet<>();
+    static List<Set<Ball>> setList = new ArrayList<>();
+    public static void main(String[] args) {
+            n = input.nextInt();
+            m = input.nextInt();
+            a = input.nextInt();
+            b = input.nextInt();
+            k = input.nextInt();
+            s = input.nextInt();
+
+        for (int i = 1; i <= n; i++) {
+            for (int j = 1; j <= a; j++) {
+                balls.add(new Ball(j,i));
+            }
+        }
+        for (int i = n+1; i <= m+n; i++) {
+            for (int j = 1; j <= b; j++) {
+                balls.add(new Ball(j,i));
+            }
+        }
+            if (s==1){
+                //for (int i = 0; i < balls.size(); i++) {
+                //    dfs1(i);
+                //    dfs1(i+1);
+                //}
+                count = dfs1(0);
+                //count = colorDFS(0)*idDFS(0);
+                System.out.println(count%998_244_353);
+            }else {
+
+            }
+    }
+
+    /**
+     * 编号的排列组合
+     * @return int
+     * @description:
+     * @author: 杨逸
+     * @data:2024/10/12 15:47:08
+     * @since 1.0.0
+     */
+    private static int idDFS(int index) {
+        int result = 0;
+        int len = a>b?a:b;
+        if (len >= currentBallIds1.size()){
+            return 1;
+        }
+        if (index>=len)return result;
+        for (int i = 0; i < len; i++) {
+            if (currentBallIds1.contains(i))continue;
+            currentBallIds1.add(i);
+            result+=idDFS(index+1);
+            //选
+            currentBallIds1.remove(i);
+            result+=idDFS(index+1);
+            //不选
+        }
+        return result;
+    }
+
+    /**
+     * 颜色的排列组合
+     * @return int
+     * @description:
+     * @author: 杨逸
+     * @data:2024/10/12 15:46:51
+     * @since 1.0.0
+     */
+    private static int colorDFS(int index) {
+        if (k==currentBallColors1.size()){
+            return 1;
+        }
+        int result = 0;
+        if (index>=n+m)return result;
+        for (int i = index; i < n + m; i++) {
+            if (currentBallColors1.contains(i))continue;
+            currentBallColors1.add(i);
+        //选这个颜色
+             result += colorDFS(index+1);
+             currentBallColors1.remove(i);
+        //不选这个颜色
+            result+=colorDFS(index+1);
+        }
+        return result;
+    }
+
+    private static long dfs1(int index) {
+        long result = 0L;
+        if (k == currentBalls1.size()){
+            //count++;
+            return valid();
+            //for (Ball ball : currentBalls1) {
+            //    System.out.println(ball);
+            //}
+            //System.out.println("=====");
+            //return 1;
+        }
+        if (index>= balls.size())return result;
+        Ball ball = balls.get(index);
+        if (currentBallIds1.contains(ball.id)||currentBallColors1.contains(ball.color)){
+            //不选
+            result+=dfs1(index+1);
+        }else {
+            //选
+            currentBalls1.add(ball);
+            currentBallIds1.add(ball.id);
+            currentBallColors1.add(ball.color);
+            result+=dfs1(index+1);
+            currentBallColors1.remove(ball.color);
+            currentBallIds1.remove(ball.id);
+            currentBalls1.remove(ball);
+            //不选
+            result+=dfs1(index+1);
+        }
+
+
+        //for (Ball ball : balls) {
+        //    if (currentBalls1.contains(ball)||currentBallIds1.contains(ball.id)||currentBallColors1.contains(ball.color))continue;
+        //    //选
+        //    currentBalls1.add(ball);
+        //    currentBallIds1.add(ball.id);
+        //    currentBallColors1.add(ball.color);
+        //    dfs1();
+        //    currentBallColors1.add(ball.color);
+        //    currentBallIds1.remove(ball.id);
+        //    currentBalls1.remove(ball);
+        //    //不选
+        //    dfs1();
+        //}
+        return result;
+    }
+
+    private static int valid() {
+        if (setList.size()!=0){
+            for (Set<Ball> ballSet : setList) {
+                if (currentBalls1.contains(ballSet)) {
+                    return 0;
+                }
+                boolean flag = true;
+                for (Ball ball : currentBalls1) {
+                    //有一个不存在即可
+                    flag = flag && ballSet.contains(ball);
+                    if (flag==false){
+                        break;
+                    }
+                }
+                if (flag){
+                    return 0;
+                }
+            }
+        }
+        HashSet<Ball> balls = new HashSet<>();
+        for (Ball ball : currentBalls1) {
+            balls.add(ball);
+        }
+        setList.add(balls);
+        return 1;
+    }
+}
+
+class Ball{
+    public Ball(int id, int color) {
+        this.id = id;
+        this.color = color;
+    }
+
+    @Override
+    public String toString() {
+        return "Ball{" +
+                "id=" + id +
+                ", color=" + color +
+                '}';
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        Ball ball = (Ball) o;
+        return id == ball.id && color == ball.color;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(color);
+    }
+
+    int id;//编号
+    int color;//颜色
+}

+ 45 - 0
src/CSP/A201312/A1/Main.java

@@ -0,0 +1,45 @@
+package CSP.A201312.A1;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 14:30
+ * @Description: 出现次数最多的数-第一题
+ */
+public class Main {
+    private static int n;
+    private static Map<Integer,Integer> numCount;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        n = scanner.nextInt();
+        numCount = new HashMap<Integer,Integer>();
+        //数据输入
+        for (int i = 0; i < n; i++) {
+            int value = scanner.nextInt();
+            if (numCount.containsKey(value)){
+                numCount.put(value,numCount.get(value)+1);
+            }else{
+                numCount.put(value,1);
+            }
+        }
+        //统计出现最多的次数
+        int max = 0;
+        for (Integer value : numCount.values()) {
+            if (value > max) max = value;
+        }
+
+        //获得出现次数最多的数,且是次数最多数值最小的数
+        int min = Integer.MAX_VALUE;
+        for (Integer integer : numCount.keySet()) {
+            int temp = numCount.get(integer);
+            if (temp == max && integer < min){
+                min = integer;
+            }
+        }
+        System.out.println(min);
+    }
+}

+ 96 - 0
src/CSP/A201612/A2/Main.java

@@ -0,0 +1,96 @@
+package CSP.A201612.A2;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 20:06
+ * @Description: 工资计算-第二题
+ */
+public class Main {
+    private static int T = 0;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        T = scanner.nextInt();
+        double S = 0;
+        //是否需要缴税
+        if (T <= 3500){
+            //不需要缴税
+            S  = T;
+            System.out.println((int) S);
+            return;
+        }
+        S = 3500;
+        T -= 3500;
+        //第一档缴税标准
+        if (T <= 1455){
+            S += T / 0.97;
+            printS((int)S);
+            return;
+        }
+        S += 1500;
+        T -= 1455;
+
+        //第二档缴税标准
+        if (T <= 2700){
+            S += T / 0.9;
+            printS((int)S);
+            return;
+        }
+        S += 3000;
+        T -= 2700;
+
+        //第三档缴税标准
+        if (T <= 3600){
+            S += T / 0.8;
+            printS((int)S);
+            return;
+        }
+        S += 4500;
+        T -= 3600;
+
+        //第四档缴税标准
+        if (T <= 19500){
+            S += T / 0.75;
+            printS((int)S);
+            return;
+        }
+        S += 26000;
+        T -= 19500;
+
+        //第五档标准
+        if (T <= 14000){
+            S += T / 0.7;
+            printS((int)S);
+            return;
+        }
+        S += 20000;
+        T -= 14000;
+
+        //第六档标准
+        if (T <= 16250){
+            S += T / 0.65;
+            printS((int)S);
+            return;
+        }
+
+        S += 25000;
+        T -= 16250;
+        //最后一档缴税标准
+
+        S += T / 0.55;
+        printS((int)S);
+
+    }
+
+    private static void printS(int S){
+        if (S%100 == 0){
+            System.out.println(S);
+        }else{
+            int rate = S/100;
+            S = (rate+1)*100;
+            System.out.println(S);
+        }
+    }
+}

+ 56 - 0
src/CSP/A202203/A1/Main.java

@@ -0,0 +1,56 @@
+package CSP.A202203.A1;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202203.A1.CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 11:27
+ * @Description: 未初始化警告-第一题
+ */
+public class Main {
+    private static int n;
+    private static int k;
+    private static Map<Integer,Integer> leftKey;
+    private static int[] rightKey;
+
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        n = scanner.nextInt();
+        k = scanner.nextInt();
+
+        leftKey = new HashMap<Integer,Integer>();
+        rightKey = new int[k];
+        //左值和右值分别保存
+        //左值保存到哈希表中,记录下出现在第几行
+        //右值保存到数组中
+        for (int i = 0; i < k; i++) {
+            int l = scanner.nextInt();
+            int r = scanner.nextInt();
+            if (!leftKey.containsKey(l)){
+                //记录变量第一次出现的时候
+                leftKey.put(l,i);
+            }
+            rightKey[i] = r;
+        }
+
+        //统计右未初始化的赋值语句条数
+        int count = 0;
+        for (int i = 0; i < rightKey.length; i++) {
+            if (rightKey[i] != 0){
+                //0一般认为是常量
+                Integer integer = leftKey.get(rightKey[i]);
+                if (integer == null || integer>= i){
+                    //没有该变量或者变量出现的行数在当前行的后面
+                    count++;
+                }
+            }
+        }
+
+        //输出结果
+
+        System.out.println(count);
+    }
+}

+ 67 - 0
src/CSP/A202203/A2/Main.java

@@ -0,0 +1,67 @@
+package CSP.A202203.A2;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/30 15:43
+ * @Description: 出行计划-第二题
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static Map<Integer,List<Integer>> map = new HashMap<>();
+    private static int[] result;
+    private static int[][] date;
+    private static int n;
+    private static int m;
+    private static int k;
+    public static void main(String[] args) {
+        n = input.nextInt();
+        m = input.nextInt();
+        k = input.nextInt();
+        //按出行时间取哈希,保存不同出现时间的核酸要求
+        result  = new int[m];
+        if (n <= 1000) {
+            date = new int[n][2];
+            //保存出现时间
+            for (int i = 0; i < n; i++) {
+                date[i] = new int[]{input.nextInt(),input.nextInt()};
+            }
+            for (int i = 0; i < m; i++) {
+                int count = 0;
+                int start = input.nextInt()+k;
+                for (int j = 0; j < n; j++) {
+                    if (date[j][0] >= start && start+date[j][1] > date[j][0])count++;
+                }
+                result[i] = count;
+            }
+
+        }else {
+            int max  =0;
+            for (int i = 0; i < n; i++) {
+                int key = input.nextInt();
+                List<Integer> temp = map.getOrDefault(key, new ArrayList<Integer>());
+                int val = input.nextInt();
+                if (val > max)max = val;
+                temp.add(val);
+                map.put(key, temp);
+            }
+            for (int i = 0; i < m; i++) {
+                int count = 0;
+                int start = input.nextInt() + k;
+                for (int j = start; j <=max; j++) {
+                    List<Integer> list = map.getOrDefault(j, new ArrayList<>());
+                    for (Integer integer : list) {
+                        if (j < start + integer) count++;
+                    }
+                }
+                result[i] = count;
+            }
+        }
+        for (int i : result) {
+            System.out.println(i);
+        }
+    }
+}

+ 44 - 0
src/CSP/A202206/A1/Main.java

@@ -0,0 +1,44 @@
+package CSP.A202206.A1; /**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202303.A1.CSP.A202212.A1.CSP.A202209.A1.CSP.A202203.A1.CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/15 10:27
+ * @Description: 归一化处理-第一题
+ */
+import java.util.Arrays;
+import java.util.Scanner;
+
+public class Main {
+    //平均值
+    public static double avg;
+    //方差
+    public static double variance;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        //输入n个数据
+        int n = scanner.nextInt();
+
+        //保存输出的结果
+        double[] input = new double[n];
+        //保存输出结果
+        double[] result = new double[n];
+
+        //输入数据
+        for (int i = 0; i < n; i++) {
+            input[i] = scanner.nextInt();
+        }
+
+        //计算平均值
+        avg = Arrays.stream(input).sum()/n;
+        //计算方差
+        variance = Arrays.stream(input).map(operand -> (operand - avg)*(operand - avg)).sum()/n;
+        //计算结果
+        for (int i = 0; i < input.length; i++) {
+            result[i] = (input[i] - avg)/Math.sqrt(variance);
+        }
+        //输出
+        for (double v : result) {
+            System.out.println(v);
+        }
+    }
+}

+ 124 - 0
src/CSP/A202206/A2/Main.java

@@ -0,0 +1,124 @@
+package CSP.A202206.A2;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/30 14:07
+ * @Description: 寻宝!大冒险!-第二题
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static List<List<Integer>> data = new ArrayList<>();
+    //保存树的坐标
+    private static Map<T,T> map = new HashMap<>();
+    private static int[][] Sgrid;
+    private static int[][] Lgrid;
+    private static int n;
+    private static int L;
+    private static int S;
+    public static void main(String[] args) {
+        n = input.nextInt();
+        L = input.nextInt();
+        S = input.nextInt();
+        Sgrid = new int[S+1][S+1];
+
+        int count = 0;
+        if (L <= 2000){
+            Lgrid = new int[L+1][L+1];
+            //还原绿化图
+            for (int i = 0; i < n; i++) {
+                int x = input.nextInt(),y = input.nextInt();
+                ArrayList<Integer> temp = new ArrayList<>();
+                temp.add(x);
+                temp.add(y);
+                data.add(temp);
+                Lgrid[x][y] = 1;
+            }
+            //将宝藏图反转输入
+            for (int i = 0; i <= S; i++) {
+                for (int j = 0; j <= S; j++) {
+                    Sgrid[S-i][j] = input.nextInt();
+                }
+            }
+
+            //对比坐标
+            for (int i = 0; i < n; i++) {
+                List<Integer> list = data.get(i);
+                int x0 = list.get(0),y0 = list.get(1);
+                boolean flag = true;
+                //越界则跳过
+                if (x0+S > L || y0 + S > L)continue;
+                for (int k = 0; k <= S; k++) {
+                    for (int j = 0; j <= S; j++) {
+                        if (Sgrid[k][j] != Lgrid[k+x0][j+y0]){
+                            flag = false;
+                            break;
+                        }
+                    }
+                        if (!flag)break;
+                }
+                if (flag)count++;
+            }
+            System.out.println(count);
+        }else {
+            //读取坐标
+            for (int i = 0; i < n; i++) {
+                T t = new T(input.nextInt(),input.nextInt());
+                map.put(t,t);
+            }
+
+            //将宝藏图反转输入
+            for (int i = 0; i <= S; i++) {
+                for (int j = 0; j <= S; j++) {
+                    Sgrid[S-i][j] = input.nextInt();
+                }
+            }
+
+            //对比坐标
+            for (T t : map.keySet()) {
+                int x0 = t.x,y0 = t.y;
+                boolean flag = true;
+                //越界则跳过
+                if (x0+S > L || y0 + S > L)continue;
+                for (int k = 0; k <= S; k++) {
+                    for (int j = 0; j <= S; j++) {
+                        if ((Sgrid[k][j]==1 && !map.containsKey(new T(k+x0,j+y0)))|| ((Sgrid[k][j]==0 && map.containsKey(new T(k+x0,j+y0))))){
+                            flag = false;
+                            break;
+                        }
+                    }
+                    if (!flag)break;
+                }
+                if (flag)count++;
+            }
+            System.out.println(count);
+        }
+
+
+
+
+    }
+}
+class T{
+    int x;
+    int y;
+
+    public T(int x, int y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    @Override
+    public int hashCode() {
+        return 1;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        T o = (T)obj;
+        return this.x == o.x && this.y == o.y;
+    }
+}

+ 49 - 0
src/CSP/A202209/A1/Main.java

@@ -0,0 +1,49 @@
+package CSP.A202209.A1;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202209.A1.CSP.A202203.A1.CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 10:37
+ * @Description: 如此编码-第一题
+ */
+public class Main {
+    private static int n;
+    private static int code;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        n = scanner.nextInt();
+        code = scanner.nextInt();
+        int[] data = new int[n];
+        int[] c = new int[n+1];
+        int[] b = new int[n];
+        //输入题目的选项数量
+        for (int i = 0; i < data.length; i++) {
+            data[i] = scanner.nextInt();
+        }
+
+        //计算c
+        c[0] = 1;
+        for (int i = 0; i < data.length; i++) {
+            int temp = data[i];
+            c[i+1] = temp*c[i];
+        }
+
+        //计算b
+        //使用动态规划计算,pd保存多项式的前 (n-1) 项的和
+        int[] pd = new int[n];
+        b[0] = (code % c[1])/c[0];
+        pd[0] = b[0]*c[0];
+        for (int i = 1; i < b.length; i++) {
+            b[i] = ((code % c[i+1]) - pd[i-1])/c[i];
+            pd[i] = pd[i-1] + b[i]*c[i];
+        }
+
+        //输出结果,调整格式
+        System.out.print(b[0]);
+        for (int i = 1; i < b.length; i++) {
+            System.out.print(" " + b[i]);
+        }
+    }
+}

+ 38 - 0
src/CSP/A202209/A2/Main.java

@@ -0,0 +1,38 @@
+package CSP.A202209.A2;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/30 11:09
+ * @Description: 何以包邮-第二题
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static int n;
+    private static int x;
+    private static int min;
+    private static int[] data;
+
+    public static void main(String[] args) {
+        n = input.nextInt();
+        x = input.nextInt();
+        min = Integer.MAX_VALUE;
+        data = new int[n];
+        for (int i = 0; i < n; i++) {
+            data[i] = input.nextInt();
+        }
+        dfs(0,0);
+
+        System.out.println(min);
+    }
+    private static void dfs(int index,int val){
+        if (val>=x && val < min)min = val;
+        if (index >= n)return;
+        //if (val > min)return;
+        dfs(index+1,val);
+        dfs(index+1,val+data[index]);
+        return;
+    }
+}

+ 33 - 0
src/CSP/A202212/A1/Main.java

@@ -0,0 +1,33 @@
+package CSP.A202212.A1; /**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202212.A1.CSP.A202209.A1.CSP.A202203.A1.CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 10:24
+ * @Description: 现值计算-第一题
+ */
+import java.util.Scanner;
+public class Main {
+    private static int n;
+    private static double rate;
+    public static void main(String[] args) {
+        //数据输入
+        Scanner scanner = new Scanner(System.in);
+        n = scanner.nextInt();
+        rate = scanner.nextDouble();
+
+        //使用一个数组保存未来的收支情况
+        double[] data = new double[n+1];
+        for (int i = 0; i < data.length; i++) {
+            data[i] = scanner.nextDouble();
+        }
+
+        double result = 0;
+        //计算收益
+        for (int i = 0; i < data.length; i++) {
+            result += Math.pow((1.0+rate),-i)*data[i];
+        }
+        //输出结果
+        System.out.println(result);
+    }
+
+}

+ 108 - 0
src/CSP/A202212/A2/Main.java

@@ -0,0 +1,108 @@
+package CSP.A202212.A2;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/23 14:46
+ * @Description: 训练计划-第二题
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    public static void main(String[] args) {
+        int n = input.nextInt();
+        int m = input.nextInt();
+        //记录最长的训练天数
+        int max = 0;
+        int[] start1 = new int[m];
+        int[] start2 = new int[m];
+        for (int i = 0; i < start2.length; i++) {
+            start2[i] = Integer.MAX_VALUE;
+        }
+        Map<Integer,P> map = new HashMap<>();
+        for (int i = 0; i < m; i++) {
+            //创建训练项目
+            P p1 = new P(i+1);
+            int pre = input.nextInt();
+            if (pre!=0){
+                //设置前置训练项目
+                P p2 = map.get(pre);
+                p1.pre = p2;
+                p2.next = p1;
+            }
+            map.put(i+1,p1);
+        }
+        for (int i = 0; i < m; i++) {
+            //设置训练时间
+           map.get(i+1).time = input.nextInt();
+        }
+        //链表
+        for (int i = 0; i < m; i++) {
+            P p = map.get(i+1);
+            int temp = p.time;
+            //最早开始时间
+            int t = 1;
+            while(p.pre != null){
+                p = p.pre;
+                t += p.time;
+            }
+            start1[i] = t;
+            if (temp+t>max)max = temp+t;
+            //start2[i]  = n - (temp+t)+2;
+        }
+
+        for (int i : start1) {
+            System.out.print(i + " ");
+        }
+        if (max-1 > n)return;
+
+        //for (int i = 0; i < m; i++) {
+        //    CSP.A202212.A2.P p = map.get(i+1);
+        //    int t = p.time;
+        //    while(p.next!=null){
+        //        p = p.next;
+        //        t += p.time;
+        //    }
+        //    start2[i] = n-t+1;
+        //}
+        for (int i = 0; i < m; i++) {
+            P p = map.get(i + 1);
+            P temp = p;
+            int sum = temp.time;
+            if (temp.next == null && temp.pre != null){
+                while(temp.pre != null){
+                    temp = temp.pre;
+                    sum += temp.time;
+                }
+                temp = p;
+                int total = n+(n-sum);
+                while(temp != null){
+                    if (start2[temp.code-1] > total - temp.time + 1)start2[temp.code-1]  = total - temp.time + 1;
+                    sum -= temp.time;
+                    total -=temp.time;
+                    temp = temp.pre;
+                }
+            }else if (temp.next == null && temp.pre == null){
+            //没有前置训练项目,也不是其他训练项目的前置
+                start2[i] = n - sum+1;
+            }
+        }
+        //打印最晚开始时间
+        System.out.println();
+        for (int i : start2) {
+            System.out.print(i + " ");
+        }
+    }
+}
+class P{
+    int code;
+    int time;
+    P next = null;
+    P pre = null;
+
+    public P(int code) {
+        this.code = code;
+    }
+}

+ 135 - 0
src/CSP/A202212/A3/Main.java

@@ -0,0 +1,135 @@
+package CSP.A202212.A3;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 11:22
+ * @Description: JPEG解码-第三题
+ */
+public class Main {
+    //使用静态代码快初始化扫描数的索引位置
+    static {
+        index = new int[][]{
+                {0,0},
+                {0,1},{1,0},
+                {2,0},{1,1},{0,2},
+                {0,3},{1,2},{2,1},{3,0},
+                {4,0},{3,1},{2,2},{1,3},{0,4},
+                {0,5},{1,4},{2,3},{3,2},{4,1},{5,0},
+                {6,0},{5,1},{4,2},{3,3},{2,4},{1,5},{0,6},
+                {0,7},{1,6},{2,5},{3,4},{4,3},{5,2},{6,1},{7,0},
+                {7,1},{6,2},{5,3},{4,4},{3,5},{2,6},{1,7},
+                {2,7},{3,6},{4,5},{5,4},{6,3},{7,2},
+                {7,3},{6,4},{5,5},{4,6},{3,7},
+                {4,7},{5,6},{6,5},{7,4},
+                {7,5},{6,6},{5,7},
+                {6,7},{7,6},
+                {7,7}};
+    }
+    private final static Scanner input = new Scanner(System.in);
+    private static int T;
+    private static int[][] Q = new int[8][8];
+    private static double[][] M = new double[8][8];
+    private static int[][] index;
+
+    public static void main(String[] args) {
+        //量化矩阵Q
+        for (int i = 0; i < 8; i++) {
+            for (int j = 0; j < 8; j++) {
+                Q[i][j] = input.nextInt();
+            }
+        }
+
+        //扫描数个数
+        int n = input.nextInt();
+        //操作编号
+        T = input.nextInt();
+        //填充扫描数
+        for (int i = 0; i < n; i++) {
+            M[index[i][0]][index[i][1]] = input.nextDouble();
+        }
+        // T为0时
+        if (T==0){
+            printM();
+            return;
+        }
+
+        //矩阵乘法
+        for (int i = 0; i < 8; i++) {
+            for (int j = 0; j < 8; j++) {
+                M[i][j] = M[i][j]*Q[i][j];
+            }
+        }
+        //T为1时
+        if (T==1){
+            printM();
+            return;
+        }
+        //离散余弦变换
+        double[][] t = new double[8][8];
+        for (int i = 0; i < M.length; i++) {
+            for (int j = 0; j < M[0].length; j++) {
+                t[i][j] = cosParse(i,j);
+            }
+        }
+        for (int i = 0; i < 8; i++) {
+            for (int j = 0; j < 8; j++) {
+                M[i][j] = t[i][j];
+            }
+        }
+        //输出最后结果
+        for (double[] doubles : M) {
+            for (double v : doubles) {
+                v = Math.round(v+128);
+                if (v>255){
+                    v = 255;
+                }else if (v<0){
+                    v = 0;
+                }
+                System.out.print((int)v+ " ");
+            }
+            System.out.println();
+        }
+    }
+
+    //离散余弦变换
+    private static double cosParse(int x,int y){
+        double temp = 0;
+        for (int i = 0; i < 8; i++) {
+            for (int j = 0; j < 8; j++) {
+                temp += f(i)*f(j)*M[i][j]*Math.cos(Math.PI/8*(x+0.5)*i)*Math.cos(Math.PI/8*(y+0.5)*j);
+            }
+        }
+        return temp/4;
+    }
+
+    private static double f(int n){
+        if (n==0){
+            return Math.sqrt(0.5);
+        }else {
+            return 1;
+        }
+    }
+
+    private static void printM(){
+        for (double[] doubles : M) {
+            for (double v : doubles) {
+                System.out.print((int)(v) + " ");
+            }
+            System.out.println();
+        }
+    }
+}
+//16 11 10 16 24 40 51 61
+//        12 12 14 19 26 58 60 55
+//        14 13 16 24 40 57 69 56
+//        14 17 22 29 51 87 80 62
+//        18 22 37 56 68 109 103 77
+//        24 35 55 64 81 104 113 92
+//        49 64 78 87 103 121 120 101
+//        72 92 95 98 112 100 103 99
+//        26
+//        1
+//        -26 -3 0 -3 -2 -6 2 -4 1 -3 1 1 5 1 2 -1 1 -1 2 0 0 0 0 0 -1 -1

+ 83 - 0
src/CSP/A202303/A1/Main.java

@@ -0,0 +1,83 @@
+package CSP.A202303.A1; /**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202303.A1.CSP.A202212.A1.CSP.A202209.A1.CSP.A202203.A1.CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 9:49
+ * @Description: 丈量土地-第一题
+ */
+import java.util.Scanner;
+public class Main {
+    private static int a;
+    private static int b;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        int n = scanner.nextInt();
+        a = scanner.nextInt();
+        b = scanner.nextInt();
+
+        int sum = 0;
+        //使用二维数组保存土地的坐标
+        int[][] data = new int[n][4];
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < 4; j++) {
+                data[i][j] = scanner.nextInt();
+            }
+        }
+
+        //遍历计算,面积
+        for (int i = 0; i < n; i++) {
+            int x1 = data[i][0];
+            int y1 = data[i][1];
+            int x2 = data[i][2];
+            int y2 = data[i][3];
+            //先排除超出范围的情况
+            if ((x1 < 0 && x2 < 0) || (x1 >a && x2 > a) || (y1 < 0 && y2 < 0) || (y1 > b && y2 > b)){
+                continue;
+            }
+            //计算在范围内的宽width
+            int width = 0;
+            if ((x1 < 0 && (x2 >= 0 && x2 <= a)) || (x2 < 0 && (x1 >= 0 && x1 <= a))){
+                //一个越高左边界一个在范围内
+                if (x1 < 0){
+                    width = x2;
+                }else{
+                    width = x1;
+                }
+            }else if ((x1 > a && (x2 >= 0 && x2 <= a)) || (x2 > a && (x1 >= 0 && x1 <= a))){
+                //一个越高右边界,一个在范围内
+                if (x1 > a){
+                    width = a - x2;
+                }else{
+                    width = a - x1;
+                }
+            }else{
+                //两个都在范围内
+                width = Math.abs(x1-x2);
+            }
+            //计算在范围内的高high
+            int high = 0;
+            if ((y1 < 0 && (y2 >= 0 && y2 <= b)) || (y2 < 0 && (y1 >= 0 && y1 <= b))){
+                //一个越高下边界,一个在范围内
+                if (y1 < 0){
+                    high = y2;
+                }else{
+                    high = y1;
+                }
+            }else if ((y1 > b && (y2 >= 0 && y2 <= b)) || (y2 > b && (y1 >= 0 && y1 <= b))){
+                //一个越高上边界,一个在范围内
+                if (y1 > b){
+                    high = b - y2;
+                }else{
+                    high = b - y1;
+                }
+            }else {
+                //两个都在范围内
+                high = Math.abs(y1-y2);
+            }
+            //计算在范围内的面积
+            sum += width*high;
+        }
+
+        System.out.println(sum);
+    }
+}

+ 65 - 0
src/CSP/A202303/A2/Main.java

@@ -0,0 +1,65 @@
+package CSP.A202303.A2;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 18:58
+ * @Description: 开垦田地-第二题
+ */
+
+public class Main {
+
+
+
+    private static int n;
+    private static int m;
+    private static int k;
+   //保存每一块田地的优先队列
+    public static Queue<Main>  queue = new PriorityQueue<>((o1, o2) -> o2.T - o1.T);
+
+    //将封装田地的属性
+    public int T;
+    public int C;
+
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        n = scanner.nextInt();
+        m = scanner.nextInt();
+        k = scanner.nextInt();
+        //数据输入
+        for (int i = 0; i < n; i++) {
+            queue.add(new Main(scanner.nextInt(),scanner.nextInt()));
+        }
+
+        while(true){
+            //取出队列头的值,并修改
+            Main node = queue.poll();
+            if (node.T > k && m > node.C){
+                //满足条件,修改天数
+                if (node.T > 3000*k && m > node.C*3000){
+                    node.T -= 3000;
+                    m -= node.C*3000;
+                }else{
+                node.T -=1;
+                m -= node.C;
+                }
+            queue.add(node);
+            }else{
+                //没有满足条件的田地,退出循环
+            queue.add(node);
+                break;
+            }
+        }
+
+        //输出最大天数
+        System.out.println(queue.poll().T);
+    }
+
+    public Main(int t, int c) {
+        T = t;
+        C = c;
+    }
+}

+ 248 - 0
src/CSP/A202303/A3/Main.java

@@ -0,0 +1,248 @@
+package CSP.A202303.A3;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/31 20:40
+ * @Description: LDAP-第二题
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private final static Map<Integer, User> users = new HashMap<>();
+    private final static List<List<Integer>> result = new ArrayList<>();
+    private static int n;
+    private static int m;
+
+    public static void main(String[] args) {
+        n = input.nextInt();
+        for (int i = 0; i < n; i++) {
+            int code = input.nextInt();
+            //根据编号创建用户
+            User user = new User(code);
+            users.put(code, user);
+            int count = input.nextInt();
+            for (int j = 0; j < count; j++) {
+                //设置用户的属性
+                user.attribute.put(input.nextInt(), input.nextInt());
+            }
+        }
+
+        //输入查询数量
+        m = input.nextInt();
+        //创建结果列表
+        for (int i = 0; i < m; i++) {
+            result.add(new ArrayList<>());
+        }
+        //进行查询
+        StringBuilder temp = new StringBuilder();
+        for (int i = 0; i < m; i++) {
+            String sentence = input.next();
+            List<Integer> list = result.get(i);
+            //将查询字符串分割为多个基础表达式
+            temp.delete(0, temp.length());
+            int left = 0;
+            //判断是否有两个组合的逻辑表达式
+            int index = -1;
+            for (int j = 1; j < sentence.length(); j++) {
+                if ((sentence.charAt(j-1)=='&' && sentence.charAt(j)=='&') || (sentence.charAt(j-1)=='&' && sentence.charAt(j)=='|') ||
+                        (sentence.charAt(j-1)=='|' && sentence.charAt(j)=='&') || (sentence.charAt(j-1)=='|' && sentence.charAt(j)=='|')){
+                    index = j-1;
+                    break;
+                }
+            }
+            if (index != -1){
+                //存在两个组合逻辑表达式
+                List<Integer> list1 = f2(sentence.substring(0, index));
+                List<Integer> list2 = f2(sentence.substring(index+1, sentence.length()));
+                //根据组合逻辑进行集合运算
+                if (sentence.charAt(index)=='|'){
+                    //进行或操作
+                    for (Integer integer : list1) {
+                        if (!list2.contains(integer))list2.add(integer);
+                    }
+                    for (Integer integer : list2) {
+                        list.add(integer);
+                    }
+                }else {
+                    //进行与操作
+                    for (Integer integer : list1) {
+                        if (list2.contains(integer))list.add(integer);
+                    }
+                }
+            }else{
+                //只有一个逻辑表达式
+                List<Integer> list1 = f2(sentence);
+                //保存到结果集合
+                for (Integer integer : list1) {
+                    list.add(integer);
+                }
+            }
+
+        }
+
+        //对查询结果进行排序
+        for (List<Integer> list : result) {
+            list.sort((v1, v2) -> v1 - v2);
+        }
+        //输出查询结果
+
+        for (List<Integer> list : result) {
+            for (Integer integer : list) {
+                System.out.print(integer + " ");
+            }
+            System.out.println();
+        }
+    }
+
+    //传进一个原子表达式,返回操作符以及属性以及属性值
+    private static int[] f(String str) {
+        int left = 0;
+        StringBuilder temp = new StringBuilder();
+        while (left < str.length() && str.charAt(left) != ':' && str.charAt(left) != '~') {
+            temp.append(str.charAt(left++));
+        }
+        int attr = Integer.valueOf(temp.toString());
+        temp.delete(0, temp.length());
+        //操作符,true为 ":",false为 "~"
+        int operate = str.charAt(left++) == ':' ? 1 : 0;
+        //值
+        //拼接值编号
+        while (left < str.length()) {
+            temp.append(str.charAt(left++));
+        }
+        int val = Integer.valueOf(temp.toString());
+        //
+        return new int[]{operate, attr, val};
+    }
+
+    //传进表达式和保存结果的列表,返回结果列表
+    private static List<Integer> f2(String sentence){
+        List<Integer> list = new ArrayList<>();
+        StringBuilder temp = new StringBuilder();
+        int left = 0;
+        if (sentence.charAt(0)=='&' || sentence.charAt(0)=='|'){
+            //逻辑表达式
+            //判断是否与还是或
+            if (sentence.charAt(left++)=='&'){
+                //与操作
+                //先用户中选出满足条件一的
+
+                while(sentence.charAt(left) != ')' && left < sentence.length()){
+                    if (sentence.charAt(left)=='('){
+                        left++;
+                        continue;
+                    }
+                    temp.append(sentence.charAt(left++));
+                }
+                int[] f = f(temp.toString());
+                temp.delete(0,temp.length());
+                boolean flag = f[0]==1;
+                int attr = f[1];
+                int val = f[2];
+
+                //将满足条件的加入
+                ArrayList<Integer> list1 = new ArrayList<>();
+                for (Integer integer : users.keySet()) {
+                    User user = users.get(integer);
+                    if (flag && user.attribute.containsKey(attr) && user.attribute.get(attr)==val){
+                        list1.add(user.code);
+                    }else if (!flag && user.attribute.containsKey(attr) && user.attribute.get(attr)!=val){
+                        list1.add(user.code);
+                    }
+                }
+                //筛选满足剩余条件的
+                while(left < sentence.length()-1){
+                    left++;
+                    while(sentence.charAt(left) != ')' && left < sentence.length()){
+                        if (sentence.charAt(left)=='('){
+                            left++;
+                            continue;
+                        }
+                        temp.append(sentence.charAt(left++));
+                    }
+                    f = f(temp.toString());
+                    temp.delete(0,temp.length());
+                    flag = f[0]==1;
+                    attr = f[1];
+                    val = f[2];
+
+                    for (Integer integer : list1) {
+                        User user = users.get(integer);
+                        if (flag && user.attribute.containsKey(attr) && user.attribute.get(attr)==val){
+                            //满足条件,不进行操作
+                        }else if (!flag && user.attribute.containsKey(attr) && user.attribute.get(attr)!=val){
+                            //满足条件,不进行操作
+                        }else{
+                            //不满足条件删除
+                            list1.remove(Integer.valueOf(integer));
+                        }
+                    }
+                }
+                //保存最后的结果
+                for (Integer integer : list1) {
+                    list.add(integer);
+                }
+            }else {
+                //或操作
+                //将所有满足条件的用户加入结果
+                while(left < sentence.length()-1){
+                    left++;
+                    while(sentence.charAt(left) != ')' && left < sentence.length()){
+                        if (sentence.charAt(left)=='('){
+                            left++;
+                            continue;
+                        }
+                        temp.append(sentence.charAt(left++));
+                    }
+                    int[] f = f(temp.toString());
+                    temp.delete(0,temp.length());
+                    boolean flag = f[0]==1;
+                    int attr = f[1];
+                    int val = f[2];
+
+                    //到哈希表中查找
+                    for (Integer integer : users.keySet()) {
+                        User user = users.get(integer);
+                        if (flag && user.attribute.containsKey(attr) && user.attribute.get(attr)==val){
+                            if (!list.contains(Integer.valueOf(user.code)))list.add(user.code);
+                        }else if (!flag && user.attribute.containsKey(attr) && user.attribute.get(attr)!=val){
+                            if (!list.contains(Integer.valueOf(user.code)))list.add(user.code);
+                        }
+                    }
+                }
+            }
+        }else{
+            //原子表达式
+            //属性
+            //拼接属性编号
+            int[] f = f(sentence);
+            boolean flag = f[0]==1;
+            int attr = f[1];
+            int val = f[2];
+
+            //到哈希表中查找
+            for (Integer integer : users.keySet()) {
+                User user = users.get(integer);
+                if (flag && user.attribute.containsKey(attr) && user.attribute.get(attr)==val){
+                    if (!list.contains(Integer.valueOf(user.code)))list.add(user.code);
+                }else if (!flag && user.attribute.containsKey(attr) && user.attribute.get(attr)!=val){
+                    if (!list.contains(Integer.valueOf(user.code)))list.add(user.code);
+                }
+            }
+        }
+        return list;
+    }
+
+}
+class User {
+    //用户类
+    int code;
+    Map<Integer, Integer> attribute = new HashMap<>();
+
+    public User(int code) {
+        this.code = code;
+    }
+}

+ 45 - 0
src/CSP/A202305/A1/Main.java

@@ -0,0 +1,45 @@
+package CSP.A202305.A1;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A20235_1.CSP.A202303.A1.CSP.A202212.A1.CSP.A202209.A1.CSP.A202203.A1.CSP.A201312.A1.CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/4 20:27
+ * @Description: 重复局面-第一题
+ */
+import java.util.Scanner;
+
+public class Main {
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        int n = scanner.nextInt();
+        //保存局面的数组
+        String[] temp = new String[n];
+        //保存当前局面出现的次数
+        int[] count = new int[n];
+
+
+        //将一个局面拼接为一个字符串
+        for (int i = 0; i < n; i++) {
+            String t = "";
+            for (int j = 0; j < 8; j++) {
+                String next = scanner.next();
+                t = t + next;
+            }
+            temp[i] = t;
+        }
+
+        for (int i = 0; i < n; i++) {
+            int count2 =1;
+            for (int j = i-1; j >=0 ; j--) {
+                //与当前局面之前出现的局面相比
+                if (temp[i].equals(temp[j])){
+                    count2 = count2 + 1;
+                }
+            }
+            count[i] = count2;
+        }
+        for (int i = 0; i < count.length; i++) {
+            System.out.println(count[i]);
+        }
+    }
+}

+ 108 - 0
src/CSP/A202305/A2/Main.java

@@ -0,0 +1,108 @@
+package CSP.A202305.A2;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202305.A2.CSP.A202303.A2.CSP.A201612.A2.CSP.A202212.A2.CSP.A202209.A2.CSP.A202206.A2.CSP.A202203.A2.CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/16 14:47
+ * @Description: 矩阵运算-第二题
+ */
+public class Main {
+    private static int n;
+    private static int d;
+    private static long[][] Q;
+    private static long[][] K;
+    private static long[][] V;
+    private static long[] W;
+
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        //输入矩阵的规模
+        n = scanner.nextInt();
+        d = scanner.nextInt();
+        //初始化矩阵
+        Q = new long[n][d];
+        K = new long[n][d];
+        V = new long[n][d];
+        //初始化向量
+        W = new long[n];
+
+        //输入数据
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < d; j++) {
+                Q[i][j] = scanner.nextInt();
+            }
+        }
+
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < d; j++) {
+                K[i][j] = scanner.nextInt();
+            }
+        }
+
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < d; j++) {
+                V[i][j] = scanner.nextInt();
+            }
+        }
+        for (int i = 0; i < n; i++) {
+            W[i] = scanner.nextInt();
+        }
+        //将K转置
+        long[][] Kt = new long[d][n];
+        for (int i = 0; i < K.length; i++) {
+            for (int j = 0; j < K[0].length; j++) {
+                Kt[j][i] = K[i][j];
+            }
+        }
+
+        //计算矩阵Kt与矩阵V,先计算后面主要是为了降维
+        long[][] temp1 = new long[d][d];
+        for (int i = 0; i < d; i++) {
+            for (int j = 0; j < d; j++) {
+                long t = 0;
+                for (int k = 0; k < n; k++) {
+                    t += Kt[i][k]*V[k][j];
+                }
+                temp1[i][j] = t;
+            }
+        }
+
+        //计算矩阵Q与矩阵temp1
+        long[][] temp2 = new long[n][d];
+        for (int i = 0; i < n; i++) {
+            //行
+            for (int j = 0; j < d; j++) {
+                //列
+                long t = 0;
+                for (int k = 0; k < d; k++) {
+                    //列的每一个元素
+                    t += Q[i][k] * temp1[k][j];
+                }
+                temp2[i][j] = t;
+            }
+        }
+
+        //计算向量W与矩阵temp2的点乘
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < d; j++) {
+                temp2[i][j] = W[i] * temp2[i][j];
+            }
+        }
+
+        //输出结果
+        for (int i = 0; i < temp2.length; i++) {
+            for (int j = 0; j < temp2[0].length; j++) {
+                System.out.print(temp2[i][j]);
+                if (j == temp2[0].length-1){
+                    //最后一个元素打印换行
+                    System.out.println("");
+                }else{
+                    //否则打印空格
+                    System.out.print(" ");
+                }
+            }
+        }
+    }
+}

+ 192 - 0
src/CSP/A202305/A3/Main.java

@@ -0,0 +1,192 @@
+package CSP.A202305.A3;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.A202305.A3.CSP.A202303.A3.CSP.A202212.A3.CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/8/30 17:25
+ * @Description: 解压缩-第三题
+ */
+public class Main {
+    private static final Scanner input = new Scanner(System.in);
+    private static int s;
+    private static StringBuilder data = new StringBuilder();
+    private static StringBuilder result = new StringBuilder();
+    public static void main(String[] args) {
+        s = input.nextInt();
+        int row;
+        if (s%8==0){
+            row = s/8;
+        }else{
+            row = s/8+1;
+        }
+        //数据输入
+        for (int i = 0; i < row; i++) {
+            data.append(input.next());
+        }
+        //读取引导域
+        int left = 0,index = 0;
+        //保存引导区的数据
+        int[] bytes = new int[4];
+        while(index < 4){
+            String str = data.substring(left, left + 2);
+            left +=2;
+
+            int val = Integer.parseInt(str,16);
+            bytes[index++] = val&127;
+            if ((val &128)==0){
+                break;
+            }
+        }
+        //通过引导区,计算原数据的长度
+        //开始恢复数据
+        int length = 0;
+        for (int i = 0; i < bytes.length; i++) {
+            length += bytes[i]*Math.pow(128,i);
+        }
+
+        while(length > 0 && left+2 < data.length()){
+            //判断是字面量还是回溯应用
+            String str = data.substring(left, left + 2);
+            left +=2;
+            int val = Integer.parseInt(str, 16);
+            if ((val&3)==0){
+                //字面量
+                for (int i = 0; i < bytes.length; i++) {
+                    bytes[i] = 0;
+                }
+
+                //恢复字面量的长度
+                if ((val>>2) < 60){
+                    //小于60的情况
+                    result.append(data.substring(left,left+((val>>2)+1)*2));
+                    left += ((val>>2)+1)*2;
+                    length -= ((val>>2)+1);
+                }else if ((val>>2)==60){
+                    //长度为后一个字节
+                    for (int i = 0; i < 1; i++) {
+                        str = data.substring(left,left+2);
+                        left +=2;
+                        val = Integer.parseInt(str,16);
+                        bytes[i] = val;
+                    }
+                    int len = 1;
+                    for (int i = 0; i < 1; i++) {
+                        len += bytes[i]*Math.pow(128,i);
+                    }
+                    result.append(data.substring(left,left+len*2));
+                    left +=len*2;
+                    length -= len;
+                }else if ((val>>2)==61){
+                    //长度为后两个字节
+                    for (int i = 0; i < 2; i++) {
+                        str = data.substring(left,left+2);
+                        left +=2;
+                        val = Integer.parseInt(str,16);
+                        bytes[i] = val;
+                    }
+                    int len = 1;
+                    for (int i = 0; i < 2; i++) {
+                        len += bytes[i]*Math.pow(128,i);
+                    }
+                    result.append(data.substring(left,left+len*2));
+                    left +=len*2;
+                    length -= len;
+                }else if ((val>>2)==62){
+                    //后三个字节
+                    for (int i = 0; i < 3; i++) {
+                        str = data.substring(left,left+2);
+                        left +=2;
+                        val = Integer.parseInt(str,16);
+                        bytes[i] = val;
+                    }
+                    int len = 1;
+                    for (int i = 0; i < 3; i++) {
+                        len += bytes[i]*Math.pow(128,i);
+                    }
+                    result.append(data.substring(left,left+len*2));
+                    left +=len*2;
+                    length -= len;
+                }else{
+                    //后四个字节
+                    for (int i = 0; i < 4; i++) {
+                        str = data.substring(left,left+2);
+                        left +=2;
+                        val = Integer.parseInt(str,16);
+                        bytes[i] = val;
+                    }
+                    int len = 1;
+                    for (int i = 0; i < 4; i++) {
+                        len += bytes[i]*Math.pow(128,i);
+                    }
+                    result.append(data.substring(left,left+len*2));
+                    left +=len*2;
+                    length -= len;
+                }
+            }else{
+                //回溯引用
+                int len = 0;
+                int order = 0;
+                if ((val&3)==1){
+                    //01回溯引用
+                    //计算l
+                    len = ((val&28) >> 2)+4;
+
+                    //计算o
+                    order = Integer.parseInt(((val&224) >> 5)+data.substring(left,left+2),16);
+                    left += 2;
+                }else {
+                    //10回溯引用
+                    //计算l
+                    len = (val>>2)+1;
+                    //计算o
+                    order = Integer.parseInt(data.substring(left+2,left+4)+data.substring(left,left+2),16);
+                    left += 4;
+                }
+
+                //还原回溯引用的数据
+                if (len > order){
+                    int tLen = len;
+                    //反复拼接已解压的后order个字符
+                    while (tLen > order){
+                        result.append(result.substring(result.length()-order*2,result.length()));
+                        tLen -= order;
+                    }
+                    //不足order个字符,但还需要拼接
+                    if (tLen > 0){
+                        result.append(result.substring(result.length()-order*2,result.length()-order*2+tLen*2));
+                    }
+                }else{
+                    result.append(result.substring(result.length() -  2*(order),result.length() - 2*(order)+len*2));
+                }
+                length -= len;
+
+            }
+
+        }
+
+        //输出
+        left = 0;
+        while(left+16 <= result.length()){
+            System.out.println(result.substring(left,left+16));
+            left +=16;
+        }
+        if (left<result.length()){
+            System.out.println(result.substring(left,result.length()));
+        }
+    }
+}
+
+//测试用例,字面量为60
+//75
+//4824010203040506
+//0708090af03c0001
+//0203040506070809
+//0a0b0c0d0e0f0102
+//030405060708090a
+//0b0c0d0e0f010203
+//0405060708090a0b
+//0c0d0e0f01020304
+//05060708090a0b0c
+//0d0e0f

+ 17 - 0
src/CSP/StackSizeTest.java

@@ -0,0 +1,17 @@
+package CSP;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: StackSizeTest
+ * @Author: 杨逸
+ * @Data:2023/8/21 10:39
+ * @Description: JVM栈大小的测试
+ */
+public class StackSizeTest {
+    private static int size = 1;
+    public static void main(String[] args) {
+        //通过"-Xss2m"指定JVM栈的大小为2兆
+        System.out.println(size++);
+        main(args);
+    }
+}

+ 55 - 0
src/CSP/temp/A1/Main.java

@@ -0,0 +1,55 @@
+package CSP.temp.A1;
+
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.temp.A1.CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 13:27
+ * @Description: U189818 时间间隔
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static int h1;
+    private static int m1;
+    private static int s1;
+    private static int h2;
+    private static int m2;
+    private static int s2;
+    public static void main(String[] args) {
+        h1 = input.nextInt();
+        m1 = input.nextInt();
+        s1 = input.nextInt();
+        h2 = input.nextInt();
+        m2 = input.nextInt();
+        s2 = input.nextInt();
+
+        int result = 0;
+        //秒差
+        if (s2 >= s1){
+            result +=s2-s1;
+        }else{
+            //借位
+            result += s2-s1+60;
+            if (m2>0){
+                m2--;
+            }else{
+                h2--;
+                m2 += 60;
+                m2 --;
+            }
+        }
+        //分钟差
+        if (m2 >=m1){
+            result += (m2-m1)*60;
+        }else{
+            //借位
+            result += (m2-m1+60)*60;
+            h2--;
+        }
+        //小时差
+        result += (h2-h1)*3600;
+        System.out.println(result);
+
+    }
+}

+ 48 - 0
src/CSP/temp/A2/Main.java

@@ -0,0 +1,48 @@
+package CSP.temp.A2;
+
+import java.util.Deque;
+import java.util.LinkedList;
+import java.util.Scanner;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.temp.A2.CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 13:39
+ * @Description: U188794 连续数列
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static int n;
+    private static int[] data;
+    private static Deque<Integer> stack = new LinkedList<>();
+
+    public static void main(String[] args) {
+        n = input.nextInt();
+        //n <=10e6
+        int max = 0;
+        data = new int[n];
+        for (int i = 0; i < n; i++) {
+            data[i] = input.nextInt();
+        }
+        //单调栈,求下一个更大值
+
+        for (int i = 0; i < n; i++) {
+            if (max > (n-i))break;
+            //清空栈
+            stack.clear();
+            for (int j = i; j < n; j++) {
+                int val = data[j];
+                if (stack.isEmpty()){
+                    stack.push(val);
+                }else if (stack.peek()+1 == val){
+                    stack.push(val);
+                }
+            }
+            //保存最大值
+            if (stack.size()>max)max = stack.size();
+        }
+
+        System.out.println(max);
+    }
+}

+ 160 - 0
src/CSP/temp/A3/Main.java

@@ -0,0 +1,160 @@
+package CSP.temp.A3;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.temp.A3.CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 13:52
+ * @Description: U129675 移动盒子
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static List<Stack<Integer>> result = new ArrayList<>();
+    private static int n;
+    private static int m;
+    public static void main(String[] args) {
+        //盒子个数
+        n = input.nextInt();
+        m = input.nextInt();
+        //使用栈保存每个位置盒子的摆放
+        for (int i = 0; i < n; i++) {
+            //初始化盒子的位置
+            Stack<Integer> queue = new Stack<>();
+            queue.push(i);
+            result.add(queue);
+        }
+        //执行操作
+        for (int i = 0; i < m; i++) {
+            int operate = input.nextInt();
+            int x = input.nextInt();
+            int y = input.nextInt();
+
+            //判断是否需要进行下一步
+            if (!isOk(x,y))continue;
+            if (operate==1){
+                //操作1
+                //将盒子归位,放到原本的位置上
+               reset(x,y);
+               reset(y,x);
+
+                //获得y所在的位置
+                Stack<Integer> stackY = getStack(y);
+                //获得x所在的位置
+                Stack<Integer> stackX = getStack(x);
+                //将x放的y上
+                stackY.push(stackX.pop());
+            }else if (operate==2){
+                //操作2
+                //将x的盒子归位
+                reset(x,y);
+
+                //获得y所在的位置
+                Stack<Integer> stackY = getStack(y);
+                //获得x所在的位置
+                Stack<Integer> stackX = getStack(x);
+                //将x放到y的顶部
+                stackY.push(stackX.pop());
+            }else if (operate==3){
+                //操作三
+                //将y归位
+                reset(y,x);
+
+                //获得y所在的位置
+                Stack<Integer> stackY = getStack(y);
+                //获得x所在的位置
+                Stack<Integer> stackX = getStack(x);
+
+                //将x及x上面的盒子放到一个临时的栈中
+                Deque<Integer> stack = new LinkedList<>();
+                while(!stackX.isEmpty()){
+                    Integer val = stackX.pop();
+                    stack.push(val);
+                    if (val==x)break;
+                }
+
+                //将x上的所有盒子放到y上面
+                while(!stack.isEmpty()){
+                    stackY.push(stack.pop());
+                }
+            }else {
+                //操作4
+                //获得y所在的位置
+                Stack<Integer> stackY = getStack(y);
+                //获得x所在的位置
+                Stack<Integer> stackX = getStack(x);
+
+                //将x及x上面的盒子放到一个临时的栈中
+                Stack<Integer> stack = new Stack<>();
+                while(!stackX.isEmpty()){
+                    Integer val = stackX.pop();
+                    stack.push(val);
+                    if (val==x)break;
+                }
+
+                //将x所有盒子放到y上面
+                //将x上的所有盒子放到y上面
+                while(!stack.isEmpty()){
+                    stackY.push(stack.pop());
+                }
+            }
+        }
+
+        //打印结果
+        for (int i = 0; i < result.size(); i++) {
+            System.out.print(i +": ");
+            for (Integer integer : result.get(i)) {
+                System.out.print(integer + " ");
+            }
+            System.out.println();
+        }
+
+    }
+
+    //盒子归位
+    private static void reset(int x,int y){
+        //x上方的盒子归位
+
+        //找到x盒子在的位置
+        Stack<Integer> queue = null;
+        for (Stack<Integer> integers : result) {
+            if (integers.contains(Integer.valueOf(x)) && integers.contains(Integer.valueOf(y))){
+                return;
+            }else if (integers.contains(Integer.valueOf(x))){
+                queue = integers;
+                break;
+            }
+        }
+
+        //开始归位
+        while(queue.peek()!= x){
+            Integer val = queue.pop();
+            result.get(val).push(val);
+        }
+
+    }
+
+    //返回盒子n所在的位置
+    private static Stack<Integer> getStack(int n){
+        Stack<Integer> stack = null;
+        for (Stack<Integer> integers : result) {
+            if (integers.contains(Integer.valueOf(n))){
+                stack = integers;
+                break;
+            }
+        }
+        return stack;
+    }
+
+    //判断x和y是否不在同一个位置
+    private static boolean isOk(int x,int y){
+        for (Stack<Integer> integers : result) {
+            if (integers.contains(Integer.valueOf(x)) && integers.contains(Integer.valueOf(y))){
+                return false;
+            }
+        }
+        return true;
+    }
+
+}

+ 106 - 0
src/CSP/temp/A4/Main.java

@@ -0,0 +1,106 @@
+package CSP.temp.A4;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.temp.A4.CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 15:36
+ * @Description: U144818 求和方法
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static int N;
+    private static int M;
+    private static int answer = 0;
+    private static List<Integer> A = new ArrayList<>();
+    private static List<Integer> B = new ArrayList<>();
+    private static List<List<Integer>> data = new ArrayList<>();
+    private static List<Integer> temp = new ArrayList<>();
+
+    //枚举选哪一个
+    public static void main(String[] args) {
+
+        N = input.nextInt();
+        M = input.nextInt();
+        //数据输入
+        for (int i = 0; i < N; i++) {
+            A.add(input.nextInt());
+        }
+        for (int i = 0; i < N; i++) {
+            B.add(input.nextInt());
+        }
+
+        for (int i = 0; i < N; i++) {
+            ArrayList<Integer> list = new ArrayList<>();
+            Integer a = A.get(i);
+            Integer b = B.get(i);
+            if (a >= b){
+                for (int j = b; j <= a; j++) {
+                    list.add(j);
+                }
+            }else{
+                for (int j = a; j <= b; j++) {
+                    list.add(j);
+                }
+            }
+            data.add(list);
+        }
+        dfs2(0,0);
+        System.out.println(answer);
+    }
+
+    //n:A序列第n个选不选,m:B序列第m个选不选
+    private static void dfs(int n,int m){
+        //求和,判断
+       if (temp.size()>1){
+           int sum =0;
+           for (Integer integer : temp) {
+               sum += integer;
+           }
+           if (sum == M)answer++;
+
+       }
+
+       if (n < N){
+           //选A序列第n个
+           temp.add(A.get(n));
+           dfs(n+1,m);
+           //还原现场
+           temp.remove(Integer.valueOf(A.get(n)));
+
+           //不选A序列第n个
+           dfs(n+1,m);
+       }
+
+
+       if (m < N){
+           //选B序列第m个
+           temp.add(B.get(m));
+           dfs(n,m+1);
+           //还原现场
+           temp.remove(Integer.valueOf(B.get(m)));
+
+           //不选B序列第m个
+           dfs(n,m+1);
+       }
+    }
+
+    //枚举选哪一个
+    private static void dfs2(int n,int sum){
+        if (n >= N){
+            if (sum == M)answer++;
+            return;
+        }
+        List<Integer> list = data.get(n);
+        for (int i = 0; i < list.size(); i++) {
+            //选这个
+            dfs2(n+1,sum+list.get(i));
+
+            //选下一个
+        }
+    }
+}

+ 71 - 0
src/CSP/temp/A5/Main.java

@@ -0,0 +1,71 @@
+package CSP.temp.A5;
+
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: CSP.temp.A5.Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 16:09
+ * @Description: U143195 物资运输
+ */
+public class Main {
+    private final static Scanner input = new Scanner(System.in);
+    private static int n;
+    private static int k;
+    private static List<G> data = new ArrayList<>();
+    private static int answer = 0;
+
+    public static void main(String[] args) {
+        n = input.nextInt();
+        k = input.nextInt();
+        //输入货物的信息
+        for (int i = 0; i < n; i++) {
+            G g = new G(input.nextInt(), input.nextInt());
+            data.add(g);
+        }
+        //排序,按平均价值
+        //data.sort(new Comparator<CSP.temp.A5.G>() {
+        //    @Override
+        //    public int compare(CSP.temp.A5.G o1, CSP.temp.A5.G o2) {
+        //        int flag  =0;
+        //        if (o2.avg - o1.avg >= 0){
+        //            flag = 1;
+        //        }else {
+        //            flag = -1;
+        //        }
+        //        return flag;
+        //    }
+        //});
+
+        //按价值排序
+        data.sort((g1,g2)->g2.v-g1.v);
+        for (int i = 0; i < k; i++) {
+            int c = input.nextInt();
+
+            if (data.size() > 0 && c >= data.get(data.size()-1).w){
+                for (int j = 0; j < data.size(); j++) {
+                    if (data.get(j).w <= c){
+                        answer += data.get(j).v;
+                        data.remove(j);
+                        break;
+                    }
+                }
+            }
+        }
+
+        System.out.println(answer);
+    }
+}
+
+class G{
+    int w;
+    int v;
+    double avg;
+
+    public G(int w, int v) {
+        this.w = w;
+        this.v = v;
+        avg = Double.valueOf(v)/w;
+    }
+}

+ 107 - 0
src/Codec.java

@@ -0,0 +1,107 @@
+/**
+ * @Projectname: LeetCode
+ * @Filename: Codec
+ * @Author: 杨逸
+ * @Data:2023/8/21 19:27
+ * @Description: 二叉树的序列化与反序列化
+ */
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Definition for a binary tree node.
+ * public class TreeNode {
+ *     int val;
+ *     TreeNode left;
+ *     TreeNode right;
+ *     TreeNode(int x) { val = x; }
+ * }
+ */
+public class Codec {
+    private static StringBuilder data = new StringBuilder("");
+    // Encodes a tree to a single string.
+    public String serialize(TreeNode root) {
+        data.delete(0,data.length());
+        encode(root,0,true);
+        return data.toString();
+    }
+
+    // Decodes your encoded data to tree.
+    public TreeNode deserialize(String data1) {
+        return decode(data1);
+    }
+
+
+    private void encode(TreeNode root,int h,boolean isLeft){
+        if (root == null){
+            return;
+        }
+        for (int i = 0; i < h; i++) {
+            //使用 "-" 表示当前节点的高度
+            data.append(".");
+        }
+        data.append(root.val);
+        if (!isLeft){
+            //在右子节点后加 "!" 表示为右节点
+            data.append("!");
+        }
+        //递归
+        encode(root.left,h+1,true);
+        encode(root.right,h+1,false);
+    }
+
+    private TreeNode decode(String data1){
+        if (data1.equals("")){
+            return null;
+        }
+        char[] chars = data1.toCharArray();
+        Map<Integer,TreeNode> map = new HashMap<>();
+        int index = 0;
+        StringBuilder value = new StringBuilder();
+        //拼接根节点的值
+        while(index < data1.length() && chars[index] != '.'){
+            value.append(chars[index++]);
+        }
+        //构建根节点
+        TreeNode root = new TreeNode(Integer.valueOf(value.toString()));
+        map.put(0,root);
+        int count = 0;
+        while(index < chars.length){
+            count = 0;
+            //获取节点的高度
+            while(index < data1.length() && chars[index] == '.'){
+                count++;
+                index++;
+            }
+            //获取节点的值
+            value.delete(0,value.length());
+            while(index < data1.length() && chars[index] != '.' && chars[index] != '!'){
+                value.append(chars[index++]);
+            }
+            //构建节点
+            TreeNode node = new TreeNode(Integer.valueOf(value.toString()));
+            //获取当前节点的父节点
+            TreeNode cur_root = map.get(count - 1);
+            //挂载当前节点,根据后一个字符是否为 "!"进行挂载
+            if (index < data1.length() && chars[index] == '!'){
+                //右子节点
+                cur_root.right = node;
+                index++;
+            }else{
+                //左子节点
+                cur_root.left = node;
+            }
+
+            //将当前节点加入哈希表中
+            map.put(count,node);
+        }
+        return root;
+    }
+}
+
+// Your Codec object will be instantiated and called as such:
+// Codec ser = new Codec();
+// Codec deser = new Codec();
+// TreeNode ans = deser.deserialize(ser.serialize(root));

+ 137 - 0
src/Exercise.java

@@ -0,0 +1,137 @@
+import java.util.*;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: Exersice
+ * @Author: 杨逸
+ * @Data:2023/8/1 15:01
+ * @Description:
+ */
+public class Exercise {
+    public static void main(String[] args) {
+        Solution solution = new Solution();
+        Codec codec = new Codec();
+        int t1[] =  {10,5,2,6};
+        int t22[] =  {2,3,1,2,4,3};
+
+
+        int t11[][] =  {{3,2,0},{0,1,0},{0,3,0}};
+        int t12[][] =  {{4,5},{7,10},{11,12},{14,15},{16,20}};
+        List<List<Integer>> list = new ArrayList<>();
+        ArrayList<Integer> list1 = new ArrayList<>();
+        list1.add(1);
+        list1.add(3);
+        ArrayList<Integer> list2 = new ArrayList<>();
+        list2.add(3);
+        list2.add(0);
+        list2.add(1);
+        ArrayList<Integer> list3 = new ArrayList<>();
+        list3.add(2);
+        ArrayList<Integer> list4 = new ArrayList<>();
+        list4.add(0);
+        list.add(list1);
+        list.add(list2);
+        list.add(list3);
+        list.add(list4);
+        char t2[][] =  {
+                {'.','.','.','.','5','.','.','1','.'},
+                {'.','.','.','.','.','3','.','.','1'},
+                {'.','.','2','.','7','.','.','.','.'},
+                {'.','.','.','.','.','2','.','.','.'},
+                {'.','.','4','.','.','.','.','.','.'},
+                {'.','4','.','3','.','.','.','.','.'},
+                {'8','.','.','.','.','.','.','2','.'},
+                {'.','1','5','.','.','.','.','.','.'},
+                {'.','2','.','9','.','.','.','.','.'}};
+
+        String str1 = "114,117,207,117,235,82,90,67,143,146,53,108,200,91,80,223,58,170,110,236,81,90,222,160,165,195,187,199,114,235,197,187,69,129,64,214,228,78,188,67,205,94,205,169,241,202,144,240";
+
+        String str2 = "ad";
+        ListNode listNode1 = new ListNode(8);
+        ListNode listNode2 = new ListNode(9);
+        ListNode listNode3 = new ListNode(9);
+        ListNode listNode4 = new ListNode(3);
+        ListNode listNode5 = new ListNode(4);
+        ListNode listNode6 = new ListNode(5);
+        listNode1.next = listNode2;
+        listNode2.next = listNode3;
+
+        listNode4.next = listNode5;
+        listNode5.next = listNode6;
+
+        ListNode listNode7 = new ListNode(2);
+        ListNode listNode8 = new ListNode(10001);
+        ListNode listNode9 = new ListNode(10002);
+
+        listNode8.next = listNode9;
+
+        TreeNode root = new TreeNode(1);
+        TreeNode root1 = new TreeNode(2);
+        TreeNode root2 = new TreeNode(3);
+        TreeNode root3 = new TreeNode(4);
+        TreeNode root4 = new TreeNode(5);
+        TreeNode root5 = new TreeNode(6);
+        TreeNode root6 = new TreeNode(7);
+        TreeNode root7 = new TreeNode(3);
+        root.left = root1;
+        root.right = root2;
+        root2.left = root3;
+        root2.right = root4;
+
+        String serialize = codec.serialize(root);
+        System.out.println(serialize);
+        TreeNode node = codec.deserialize(serialize);
+        System.out.println("1");
+
+
+
+    }
+
+    //杨辉三角,DP
+    static void f(int n){
+        //DP
+        //使用二维数组保存数据
+        int mid = n-1;
+        int[][] dp = new int[n][2*n];
+        dp[0][mid] = 1;
+        for (int i = 1; i < n; i++) {
+            int cur_index = mid - i;
+            int size = i+1;
+            while(size != 0){
+                int v = 0;
+                //左上角
+                if (cur_index-1>=0){
+                    v+=dp[i-1][cur_index-1];
+                }
+                //右上角
+                if (cur_index+1 < 2*n){
+                    v += dp[i-1][cur_index+1];
+                }
+                dp[i][cur_index] = v;
+                cur_index +=2;
+                size--;
+            }
+        }
+        for (int[] ints : dp) {
+            for (int anInt : ints) {
+                if (anInt == 0){
+                    System.out.print("\t");
+                }else{
+                    System.out.print(anInt + "   ");
+                }
+            }
+            System.out.println("");
+        }
+    }
+
+    //杨辉三角,递归
+    static int f2(int n,int m){
+        if (n == 1 && m == 1){
+            return 1;
+        }
+        if (m < 1 || m > n){
+            return 0;
+        }
+        return f2(n-1,m-1)+ f2(n-1,m);
+    }
+}

+ 14 - 0
src/ListNode.java

@@ -0,0 +1,14 @@
+/**
+ * @Projectname: LeetCode
+ * @Filename: ListNode
+ * @Author: 杨逸
+ * @Data:2023/8/5 23:17
+ * @Description: 链表的节点
+ */
+public class ListNode {
+    int val;
+    ListNode next;
+    ListNode() {}
+    ListNode(int val) { this.val = val; }
+    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
+}

+ 12 - 0
src/Main.java

@@ -0,0 +1,12 @@
+/**
+ * @Projectname: LeetCode
+ * @Filename: Main
+ * @Author: 杨逸
+ * @Data:2023/9/2 18:44
+ * @Description:
+ */
+public class Main {
+    public static void main(String[] args) {
+        System.out.println(User.RankLevel2.level);
+    }
+}

+ 27 - 0
src/Node.java

@@ -0,0 +1,27 @@
+/**
+ * @Projectname: LeetCode
+ * @Filename: Node
+ * @Author: 杨逸
+ * @Data:2023/8/21 9:25
+ * @Description: 拥有随机指针的二叉树的节点
+ */
+public class Node {
+    public int val;
+    public Node left;
+    public Node right;
+    public Node next;
+
+    public Node() {
+    }
+
+    public Node(int val) {
+        this.val = val;
+    }
+
+    public Node(int val, Node left, Node right, Node next) {
+        this.val = val;
+        this.left = left;
+        this.right = right;
+        this.next = next;
+    }
+}

+ 22 - 0
src/Solution.java

@@ -0,0 +1,22 @@
+import java.util.Arrays;
+
+class Solution {
+    public int maxOperations(int[] nums, int k) {
+        //排序+相向双指针
+        Arrays.sort(nums);
+        int count = 0,left = 0,right = nums.length-1;
+        while (left < right){
+            int sum = nums[left] + nums[right];
+            if (sum > k){
+                right--;
+            }else if (sum < k){
+                left++;
+            }else {
+                count++;
+                left++;
+                right--;
+            }
+        }
+        return count;
+    }
+}

+ 11 - 0
src/StackTest.java

@@ -0,0 +1,11 @@
+public class StackTest {
+    public static void main(String[] args) {
+        //返回Java虚拟机中的堆内存总量
+        long xmsMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
+        //返回Java虚拟机中使用的最大堆内存
+        long xmxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;
+        System.out.println("-Xms:" + xmsMemory + "M");
+        System.out.println("-Xmx:" + xmxMemory + "M");
+
+    }
+}

+ 25 - 0
src/TreeNode.java

@@ -0,0 +1,25 @@
+/**
+ * @Projectname: LeetCode
+ * @Filename: TreeNode
+ * @Author: 杨逸
+ * @Data:2023/8/14 20:46
+ * @Description: 二叉树的节点
+ */
+public class TreeNode {
+    int val;
+    TreeNode left;
+    TreeNode right;
+
+    public TreeNode(int val, TreeNode left, TreeNode right) {
+        this.val = val;
+        this.left = left;
+        this.right = right;
+    }
+
+    public TreeNode(int val) {
+        this.val = val;
+    }
+
+    public TreeNode() {
+    }
+}

+ 23 - 0
src/User.java

@@ -0,0 +1,23 @@
+/**
+ * @Projectname: LeetCode
+ * @Filename: User
+ * @Author: 杨逸
+ * @Data:2023/9/9 14:40
+ * @Description: 测试枚举类的使用
+ */
+public enum User {
+    RankLevel1(1),RankLevel2(2);
+    int level;
+
+    private User(int level) {
+        this.level = level;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+}

+ 24 - 0
src/leetcode/p1342/Solution.java

@@ -0,0 +1,24 @@
+package leetcode.p1342;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/4/9 14:20
+ * @Description: https://leetcode.cn/problems/number-of-steps-to-reduce-a-number-to-zero/
+ * 1342. 将数字变成 0 的操作次数
+ */
+public class Solution {
+    public int numberOfSteps(int num) {
+        int count = 0;
+        while (num != 0){
+            if (num%2==0){
+                num /= 2;
+            }else {
+                num--;
+            }
+            count++;
+        }
+        return count;
+    }
+}

+ 21 - 0
src/leetcode/p1342/SolutionTest.java

@@ -0,0 +1,21 @@
+package leetcode.p1342;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/4/9 14:26
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void numberOfSteps() {
+        Solution solution = new Solution();
+        System.out.println(solution.numberOfSteps(14));
+    }
+}

+ 22 - 0
src/leetcode/p1702/Solution.java

@@ -0,0 +1,22 @@
+package leetcode.p1702;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/4/10 9:48
+ * @Description: https://leetcode.cn/problems/maximum-binary-string-after-change/description/
+ * 1702. 修改后的最大二进制字符串
+ */
+public class Solution {
+    public String maximumBinaryString(String binary) {
+        //00 --> 10
+        //10 --> 01
+
+        //000110
+        //100110
+        //110110
+        //
+    return null;
+    }
+}

+ 20 - 0
src/leetcode/p2529/Solution.java

@@ -0,0 +1,20 @@
+package leetcode.p2529;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/4/9 11:05
+ * @Description: https://leetcode.cn/problems/maximum-count-of-positive-integer-and-negative-integer/
+ * 2529. 统计正负数的最大数量
+ */
+public class Solution {
+    public int maximumCount(int[] nums) {
+        int neg = 0, pos = 0;
+        for (int num : nums) {
+            if (num < 0)neg++;
+            if (num > 0)pos++;
+        }
+        return Math.max(neg, pos);
+    }
+}

+ 25 - 0
src/leetcode/p2529/SolutionTest.java

@@ -0,0 +1,25 @@
+package leetcode.p2529;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/4/9 11:07
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void maximumCount() {
+        Solution solution = new Solution();
+
+        int[] nums = new int[]{-2,-1,-1,1,2,3};
+
+        System.out.println(solution.maximumCount(nums));
+
+    }
+}

+ 112 - 0
src/leetcode/p2892/Solution.java

@@ -0,0 +1,112 @@
+package leetcode.p2892;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/find-longest-special-substring-that-occurs-thrice-ii/description/'>2982. 找出出现至少三次的最长特殊子字符串 II</a>
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/5/30 9:39
+ * @Description:
+ * 给你一个仅由小写英文字母组成的字符串 s 。
+ *
+ * 如果一个字符串仅由单一字符组成,那么它被称为 特殊 字符串。例如,字符串 "abc" 不是特殊字符串,而字符串 "ddd"、"zz" 和 "f" 是特殊字符串。
+ *
+ * 返回在 s 中出现 至少三次 的 最长特殊子字符串 的长度,如果不存在出现至少三次的特殊子字符串,则返回 -1 。
+ *
+ * 子字符串 是字符串中的一个连续 非空 字符序列。
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:s = "aaaa"
+ * 输出:2
+ * 解释:出现三次的最长特殊子字符串是 "aa" :子字符串 "aaaa"、"aaaa" 和 "aaaa"。
+ * 可以证明最大长度是 2 。
+ * 示例 2:
+ *
+ * 输入:s = "abcdef"
+ * 输出:-1
+ * 解释:不存在出现至少三次的特殊子字符串。因此返回 -1 。
+ * 示例 3:
+ *
+ * 输入:s = "abcaba"
+ * 输出:1
+ * 解释:出现三次的最长特殊子字符串是 "a" :子字符串 "abcaba"、"abcaba" 和 "abcaba"。
+ * 可以证明最大长度是 1 。
+ *
+ *
+ * 提示:
+ *
+ * 3 <= s.length <= 5 * 105
+ * s 仅由小写英文字母组成。
+ */
+public class Solution {
+    public int maximumLength(String s) {
+        ArrayList<List<Integer>> list = new ArrayList<>(26);
+
+        for (int i = 0; i < 26; i++) {
+            list.add(new ArrayList<>());
+        }
+        //按重复字符分组,记录重复字符的长度
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            int count = 1;
+            while (i<s.length()-1){
+                if (s.charAt(i+1)==c){
+                    count++;
+                }else{
+                    break;
+                }
+                i++;
+            }
+            List<Integer> integers = list.get(c - 'a');
+            if (integers == null)integers = new ArrayList<>();
+            integers.add(count);
+        }
+
+        int result = -1;
+
+        //遍历分组,找出符合条件的最大值
+        for (List<Integer> integers : list) {
+            if (integers.size()==0)continue;
+           integers.sort((a, b) -> b - a);
+           if (integers.size()==1){
+               Integer integer = integers.get(0);
+               if (integer >=3 && result < integer - 2) {
+                   result = integer -2;
+               }
+           }else if (integers.size()==2){
+               Integer v1 = integers.get(0);
+               Integer v2 = integers.get(1);
+               if (v1.equals(v2) && result < v1 - 1 && v1-1 != 0)result = v1 - 1;
+               //差值为1的情况
+               if (v1-v2==1){
+                   if (result < v2)result = v2;
+               }else {
+                   if (v1>2 && result < v1 - 2)result = v1 - 2;
+               }
+           }else{
+               Integer v1 = integers.get(0);
+               Integer v2 = integers.get(1);
+               Integer v3 = integers.get(2);
+               //前三个重复字符长度相等
+               if (v1.equals(v3) && result < v1)result = v1;
+               if (!v1.equals(v3)){
+                   if (v1.equals(v2)){
+                       if (result < v1 - 1 && v1-1 != 0)result = v1-1;
+                   }else if (v1-v2==1){
+                       //差值为1的情况
+                       if (result < v2)result = v2;
+                   }else if (v1>2 && result < v1 - 2){
+                       result = v1 - 2;
+                   }
+               }
+           }
+        }
+        return result;
+    }
+}

+ 49 - 0
src/leetcode/p2892/SolutionTest.java

@@ -0,0 +1,49 @@
+package leetcode.p2892;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/5/30 10:16
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void maximumLength() {
+        Solution solution = new Solution();
+
+        String s = "aaaa";
+        int result = solution.maximumLength(s);
+        assertEquals(result,2);
+
+        s = "abcdef";
+        result = solution.maximumLength(s);
+        assertEquals(result,-1);
+
+        s = "abcaba";
+        result = solution.maximumLength(s);
+        assertEquals(result,1);
+
+        //cdc
+        s = "cccerrrecdcdccedecdcccddeeeddcdcddedccdceeedccecde";
+        result = solution.maximumLength(s);
+        assertEquals(result,2);
+
+        s = "jicja";
+        result = solution.maximumLength(s);
+        assertEquals(result,-1);
+
+        s = "accccerrrc";
+        result = solution.maximumLength(s);
+        assertEquals(result,2);
+
+        s = "alappaaaaapttgvvvmmc";
+        result = solution.maximumLength(s);
+        assertEquals(result,3);
+    }
+}

+ 49 - 0
src/leetcode/p2965/Solution.java

@@ -0,0 +1,49 @@
+package leetcode.p2965;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/find-missing-and-repeated-values/description/'>2965. 找出缺失和重复的数字</a>
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/5/31 8:41
+ * @Description:
+ * 给你一个下标从 0 开始的二维整数矩阵 grid,大小为 n * n ,其中的值在 [1, n2] 范围内。除了 a 出现 两次,b 缺失 之外,每个整数都 恰好出现一次 。
+ *
+ * 任务是找出重复的数字a 和缺失的数字 b 。
+ *
+ * 返回一个下标从 0 开始、长度为 2 的整数数组 ans ,其中 ans[0] 等于 a ,ans[1] 等于 b 。
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:grid = [[1,3],[2,2]]
+ * 输出:[2,4]
+ * 解释:数字 2 重复,数字 4 缺失,所以答案是 [2,4] 。
+ * 示例 2:
+ *
+ * 输入:grid = [[9,1,7],[8,9,2],[3,4,6]]
+ * 输出:[9,5]
+ * 解释:数字 9 重复,数字 5 缺失,所以答案是 [9,5] 。
+ */
+public class Solution {
+    public int[] findMissingAndRepeatedValues(int[][] grid) {
+        int n = grid.length;
+        int [] cnt = new int[n*n + 1];
+        int result[] = new int[2];
+        for (int[] row : grid) {
+            for (int v : row) {
+                cnt[v]++;
+            }
+        }
+        for (int i = 1; i < cnt.length; i++) {
+            if (cnt[i] == 0){
+                result[1]  = i;
+            }else if (cnt[i] == 2){
+                result[0] = i;
+            }
+        }
+
+        return result;
+    }
+}

+ 36 - 0
src/leetcode/p2965/SolutionTest.java

@@ -0,0 +1,36 @@
+package leetcode.p2965;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/5/31 8:46
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void findMissingAndRepeatedValues() {
+        Solution solution = new Solution();
+
+        int[][] grid ={
+                {1,3},
+                {2,2}
+        };
+        int[] ans = solution.findMissingAndRepeatedValues(grid);
+
+        assertArrayEquals(ans,new int[]{2,4});
+
+        grid =new int[][]{
+                {9,1,7},
+                {8,9,2},
+                {3,4,6},
+        };
+        ans = solution.findMissingAndRepeatedValues(grid);
+        assertArrayEquals(ans,new int[]{9,5});
+    }
+}

+ 74 - 0
src/leetcode/p2981/Solution.java

@@ -0,0 +1,74 @@
+package leetcode.p2981;
+
+import java.util.HashMap;
+import java.util.Objects;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/find-longest-special-substring-that-occurs-thrice-i/'>2981. 找出出现至少三次的最长特殊子字符串 I</a>
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/5/29 10:07
+ * @Description:
+ * 给你一个仅由小写英文字母组成的字符串 s 。
+ *
+ * 如果一个字符串仅由单一字符组成,那么它被称为 特殊 字符串。例如,字符串 "abc" 不是特殊字符串,而字符串 "ddd"、"zz" 和 "f" 是特殊字符串。
+ *
+ * 返回在 s 中出现 至少三次 的 最长特殊子字符串 的长度,如果不存在出现至少三次的特殊子字符串,则返回 -1 。
+ *
+ * 子字符串 是字符串中的一个连续 非空 字符序列。
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:s = "aaaa"
+ * 输出:2
+ * 解释:出现三次的最长特殊子字符串是 "aa" :子字符串 "aaaa"、"aaaa" 和 "aaaa"。
+ * 可以证明最大长度是 2 。
+ * 示例 2:
+ *
+ * 输入:s = "abcdef"
+ * 输出:-1
+ * 解释:不存在出现至少三次的特殊子字符串。因此返回 -1 。
+ * 示例 3:
+ *
+ * 输入:s = "abcaba"
+ * 输出:1
+ * 解释:出现三次的最长特殊子字符串是 "a" :子字符串 "abcaba"、"abcaba" 和 "abcaba"。
+ * 可以证明最大长度是 1 。
+ *
+ *
+ * 提示:
+ *
+ * 3 <= s.length <= 50
+ * s 仅由小写英文字母组成。
+ */
+public class Solution {
+    public int maximumLength(String s) {
+        HashMap<String, Integer> map = new HashMap<>();
+        int d = s.length()-2;
+        while (d>0){
+            for (int i = 0; i <= s.length()-d; i++) {
+                String key = s.substring(i, i + d);
+                if (isOk(key)) map.put(key,map.getOrDefault(key,0)+1);
+                //至少出现三次
+                Integer integer = map.get(key);
+                if (Objects.nonNull(integer) && integer >=3) {
+                    return key.length();
+                }
+            }
+            d--;
+        }
+
+        return -1;
+    }
+
+    private boolean isOk(String s){
+        char c  = s.charAt(0);
+        for (int i = 0; i < s.length(); i++) {
+            if (c != s.charAt(i))return false;
+        }
+        return true;
+    }
+}

+ 37 - 0
src/leetcode/p2981/SolutionTest.java

@@ -0,0 +1,37 @@
+package leetcode.p2981;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/5/29 10:22
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void maximumLength() {
+        Solution solution = new Solution();
+
+        String s = "aaaa";
+        int result = solution.maximumLength(s);
+        assertEquals(result,2);
+
+        s = "abcdef";
+        result = solution.maximumLength(s);
+        assertEquals(result,-1);
+
+        s = "abcaba";
+        result = solution.maximumLength(s);
+        assertEquals(result,1);
+
+        //cdc
+        s = "cccerrrecdcdccedecdcccddeeeddcdcddedccdceeedccecde";
+        result = solution.maximumLength(s);
+        assertEquals(result,2);
+    }
+}

+ 19 - 0
src/leetcode/p740/Solution.java

@@ -0,0 +1,19 @@
+package leetcode.p740;
+
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/4/9 11:21
+ * @Description: https://leetcode.cn/problems/delete-and-earn/?envType=study-plan-v2&envId=dynamic-programming
+ * 740. 删除并获得点数
+ */
+public class Solution {
+    public int deleteAndEarn(int[] nums) {
+        int result1 = 0;
+        int result2 = 0;
+        //todo:未实现
+        return 0;
+    }
+}

+ 28 - 0
src/leetcode/p740/SolutionTest.java

@@ -0,0 +1,28 @@
+package leetcode.p740;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/4/9 11:25
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void deleteAndEarn() {
+
+    }
+
+    @Test
+    public void test(){
+        Integer integer1 = 1000;
+        Integer integer2 = 1000;
+        System.out.println(integer1.equals(integer2));
+        System.out.println(integer1== (integer2));
+    }
+}

+ 21 - 0
src/leetcode/p764/Solution.java

@@ -0,0 +1,21 @@
+package leetcode.p764;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/4/9 14:34
+ * @Description: https://leetcode.cn/problems/min-cost-climbing-stairs/description/
+ * 746. 使用最小花费爬楼梯
+ */
+public class Solution {
+    public int minCostClimbingStairs(int[] cost) {
+        int[] dp = new int[cost.length];
+        dp[0] = cost[0];
+        dp[1] = cost[1];
+        for (int i = 2; i < cost.length; i++) {
+            dp[i] = Math.min(dp[i-1],dp[i-2]) + cost[i];
+        }
+        return Math.min(dp[cost.length-1],dp[cost.length-2] );
+    }
+}

+ 22 - 0
src/leetcode/p764/SolutionTest.java

@@ -0,0 +1,22 @@
+package leetcode.p764;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/4/9 14:41
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void minCostClimbingStairs() {
+        Solution solution = new Solution();
+        int[] cost = {10, 15, 20};
+        System.out.println(solution.minCostClimbingStairs(cost));
+    }
+}

+ 52 - 0
src/luogu/t1/Main.java

@@ -0,0 +1,52 @@
+package luogu.t1;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: Main
+ * @Author: 杨逸
+ * @Data:2023/11/26 13:34
+ * @Description:
+ */
+public class Main {
+    public static void main(String[] args) {
+    List<Integer> result = new ArrayList<>();
+        Scanner scanner = new Scanner(System.in);
+        Integer start = scanner.nextInt();
+        Integer end = scanner.nextInt();
+        for (Integer integer = start; integer <= end; integer++) {
+            if (isOk(integer)) {
+                result.add(integer);
+            }
+        }
+        for (Integer integer : result) {
+            System.out.println(integer);
+        }
+    }
+
+     static boolean isOk(int value){
+        int anInt = Integer.parseInt(String.valueOf(value), 10);
+         //System.out.println("anInt = " + anInt);
+        String value10 = Integer.toString(value, 10);
+        //System.out.println("value10 = " + value10);
+        String value12 = Integer.toString(value, 12);
+        //System.out.println("value12 = " + value12);
+        String value16 = Integer.toString(value, 16);
+        //System.out.println("value16 = " + value16);
+        int sum1=0,sum2=0,sum3=0;
+        for (int i = 0; i < value10.length(); i++) {
+            sum1+= Integer.parseInt(value10.charAt(i)+"",10);
+        }
+        for (int i = 0; i < value12.length(); i++) {
+            sum2+=Integer.parseInt(value12.charAt(i)+"",12);
+        }
+         for (int i = 0; i < value16.length(); i++) {
+             sum3+=Integer.parseInt(value16.charAt(i)+"",16);
+         }
+        if (sum1!=sum2)return false;
+        if (sum1!=sum3)return false;
+        return true;
+    }
+}

+ 61 - 0
src/luogu/t2/Main.java

@@ -0,0 +1,61 @@
+package luogu.t2;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: Main
+ * @Author: 杨逸
+ * @Data:2023/11/26 14:00
+ * @Description:
+ */
+public class Main {
+    static int min = Integer.MAX_VALUE;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        Integer n = scanner.nextInt();
+        List<Integer> value = new ArrayList<>();
+        for (Integer integer = 0; integer < n; integer++) {
+            value.add(scanner.nextInt());
+        }
+
+        for (int i = 0; i < value.size()-1; i++) {
+            //合
+            List<Integer> integers = new ArrayList<>(value.subList(0, i));
+            integers.add(value.get(i)+value.get(i+1));
+            for (int j = i+2; j < value.size(); j++) {
+                integers.add(value.get(j));
+            }
+            dfs(integers,0,1);
+            //不合
+            dfs(new ArrayList<Integer>(value),i+1,0);
+        }
+
+        System.out.println(min);
+    }
+
+    static void dfs(List<Integer> list,int index,int count){
+        boolean flag = true;
+        for (int i = 0; i < list.size(); i++) {
+            if (list.get(0)!=list.get(i)){
+                flag = false;
+                break;
+            }
+        }
+        if (flag){
+            min = Math.min(min,count);
+            return;
+        }
+        if (index>=list.size())return;
+        if (count>=min)return;
+        for (int i = index; i < list.size()-1; i++) {
+            List<Integer> integers = new ArrayList<>(list.subList(0, i));
+            integers.add(list.get(i)+list.get(i+1));
+            for (int j = i+2; j < list.size(); j++) {
+                integers.add(list.get(j));
+            }
+            dfs(integers,0,count+1);
+            dfs(new ArrayList<Integer>(list),i+1,count);
+        }
+    }
+}

+ 51 - 0
src/luogu/t3/Main.java

@@ -0,0 +1,51 @@
+package luogu.t3;
+import java.util.Scanner;
+/**
+ * @Projectname: LeetCode
+ * @Filename: Main
+ * @Author: 杨逸
+ * @Data:2023/11/26 14:45
+ * @Description:
+ */
+public class Main {
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        String data = scanner.nextLine();
+        int index = 0;
+        StringBuilder stringBuilder = new StringBuilder();
+        while (true){
+            if (data.charAt(index)=='0'){
+                String temp = data.substring(index+1,index+8);
+                String value = Integer.toString(Integer.parseInt(temp, 2), 16);
+                for (int i = 0; i < 4- value.length() % 4; i++) {
+                    stringBuilder.append("0");
+                }
+                stringBuilder.append(value);
+                //stringBuilder.append("00").append(Integer.toString(Integer.parseInt(temp,2),16));
+                index+=8;
+            }else if (data.charAt(index)=='1' && data.charAt(index+1)=='1'&& data.charAt(index+2)=='0'){
+                StringBuilder builder = new StringBuilder();
+                builder.append(data.substring(index+3,index+8)).append(data.substring(index+10,index+16));
+                String value = Integer.toString(Integer.parseInt(builder.toString(), 2), 16);
+                for (int i = 0; i < 4 - value.length() % 4; i++) {
+                    stringBuilder.append("0");
+                }
+                stringBuilder.append(value);
+                //stringBuilder.append("0").append(Integer.toString(Integer.parseInt(builder.toString(),2),16));
+                index+=16;
+            }else {
+                StringBuilder builder = new StringBuilder();
+                builder.append(data.substring(index+4,index+8)).append(data.substring(index+10,index+16)).append(data.substring(index+18,index+24));
+                String value = Integer.toString(Integer.parseInt(builder.toString(), 2), 16);
+                for (int i = 0; i < 4 - value.length() % 4; i++) {
+                    stringBuilder.append("0");
+                }
+                stringBuilder.append(value);
+                //stringBuilder.append(Integer.toString(Integer.parseInt(builder.toString(),2),16));
+                index+=24;
+            }
+            if (index>= data.length())break;
+        }
+        System.out.println(stringBuilder.toString().toUpperCase());
+    }
+}

+ 61 - 0
src/luogu/t4/Main.java

@@ -0,0 +1,61 @@
+package luogu.t4;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: Main
+ * @Author: 杨逸
+ * @Data:2023/11/26 15:20
+ * @Description:
+ */
+public class Main {
+        static Long result = Long.MAX_VALUE;
+        static Long temp = 0L;
+        static int[] value;
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        List<List<Integer>> data = new ArrayList<>();
+        int n = scanner.nextInt(),m = scanner.nextInt();
+        for (int i = 0; i < n; i++) {
+            ArrayList<Integer> integers = new ArrayList<>();
+            integers.add(scanner.nextInt());
+            integers.add(scanner.nextInt());
+            integers.add(scanner.nextInt());
+            data.add(integers);
+        }
+        value = new int[m];
+        dfs(data,0);
+        System.out.println(result);
+    }
+
+    static void dfs(List<List<Integer>> list,int m) {
+        boolean flag = true;
+        for (int i = 0; i < value.length; i++) {
+            if (value[i] == 0) {
+                flag = false;
+                break;
+            }
+        }
+        if (flag && temp < result) result = temp;
+        if (m >= list.size() || flag) return;
+            //选
+            List<Integer> integers = list.get(m);
+            temp += integers.get(2);
+            for (Integer integer = integers.get(0); integer <= integers.get(1); integer++) {
+                value[integer-1]++;
+            }
+
+            dfs(list,m+1);
+
+            temp -= integers.get(2);
+            for (Integer integer = integers.get(0); integer <= integers.get(1); integer++) {
+                value[integer-1]--;
+            }
+
+            //不选
+            dfs(list,m+1);
+        }
+
+}

+ 50 - 0
src/luogu/t5/Main.java

@@ -0,0 +1,50 @@
+package luogu.t5;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Scanner;
+import java.util.Set;
+
+/**
+ * @Projectname: LeetCode
+ * @Filename: Main
+ * @Author: 杨逸
+ * @Data:2023/11/26 15:45
+ * @Description:
+ */
+public class Main {
+        static int result = 0;
+        static int temp = 0;
+        static Set<Integer> path = new HashSet<>();
+    public static void main(String[] args) {
+        Scanner scanner = new Scanner(System.in);
+        int n = scanner.nextInt();
+        int[][]  graph = new int[n][n];
+        for (int i = 0; i < n-1; i++) {
+            int x = scanner.nextInt()-1;
+            int y = scanner.nextInt()-1;
+            int v = scanner.nextInt();
+            graph[x][y] = v;
+            graph[y][x] = v;
+        }
+        for (int i = 0; i < n; i++) {
+            dfs(graph,i);
+        }
+        System.out.println(result);
+
+    }
+
+    private static void dfs(int[][] graph, int number) {
+        path.add(number);
+        for (int i = 0; i < graph[0].length; i++) {
+            if (graph[number][i]>0 && path.contains(i)==false){
+                temp += graph[number][i];
+                if (temp>result)result = temp;
+                dfs(graph,i);
+                temp -= graph[number][i];
+            }
+        }
+        path.remove(number);
+    }
+
+
+}

+ 35 - 0
src/weekContest/A361/A1/Solution.java

@@ -0,0 +1,35 @@
+package weekContest.A361.A1;
+
+import java.util.HashSet;
+
+class Solution {
+    public int countSymmetricIntegers(int low, int high) {
+        //数据范围内的所有对称整数加入哈希表
+        HashSet<Integer> set = new HashSet<>();
+        int count = 0;
+        //10-99
+        for (int i = 10; i < 100; i++) {
+            if (isOK(i))set.add(i);
+        }
+        //1000-9999
+        for (int i = 1000; i < 10000; i++) {
+            if (isOK(i))set.add(i);
+        }
+
+        for (int i = low; i <= high ; i++) {
+            if (set.contains(i))count++;
+        }
+        return count;
+    }
+
+    boolean isOK(int val){
+        String str = String.valueOf(val);
+        int n = str.length()/2;
+        int sum1 = 0,sum2 = 0;
+        for (int i = 0; i < n; i++) {
+            sum1 += str.charAt(i);
+            sum2 += str.charAt(2*n-1-i);
+        }
+        return sum1==sum2;
+    }
+}

+ 23 - 0
src/weekContest/A361/A2/Solution.java

@@ -0,0 +1,23 @@
+package weekContest.A361.A2;
+
+class Solution {
+    public int minimumOperations(String num) {
+        //数字最后两位只能是25,75,00,50,或者整个字符串都是0
+        int min = Integer.MAX_VALUE;
+        //统计零的个数
+        int count = 0,firstZero = -1,firstFive =-1,zeroNext = -1,fiveNext = -1;
+        for (int i = num.length()-1; i >=0; i--) {
+            if (num.charAt(i)=='0')count++;
+            //记录出现0或5之后第一次出现2,7,5,0的位置
+            if (zeroNext == -1 && firstZero != -1 && (num.charAt(i)=='0' || num.charAt(i)=='5'))zeroNext = i;
+            if (fiveNext == -1 && firstFive != -1 && (num.charAt(i)=='2' || num.charAt(i)=='7'))fiveNext = i;
+            //记录第一次出现0和5的位置
+            if (num.charAt(i)=='0' && firstZero == -1)firstZero = i;
+            if (num.charAt(i)=='5' && firstFive == -1)firstFive = i;
+        }
+        if (zeroNext != -1 && firstZero != -1)min = Math.min(min,num.length()-zeroNext-2);
+        if (fiveNext != -1 && firstFive != -1)min = Math.min(min,num.length()-fiveNext-2);
+        min = Math.min(min,num.length() - count);
+        return min;
+    }
+}

+ 30 - 0
src/weekContest/A361/A3/Solution.java

@@ -0,0 +1,30 @@
+package weekContest.A361.A3;
+
+import java.util.HashMap;
+import java.util.List;
+
+class Solution {
+    //前缀和+同余定理+哈希表辅助统计+两数之和思想
+    public long countInterestingSubarrays(List<Integer> nums, int modulo, int k) {
+        long count = 0,pre = 0;
+        for (int i = 0; i < nums.size(); i++) {
+            if (nums.get(i)%modulo==k){
+                nums.set(i,1);
+            }else{
+                nums.set(i,0);
+            }
+        }
+        HashMap<Long, Integer> map = new HashMap<>();
+        map.put(Long.valueOf(0),1);
+
+        for (Integer num : nums) {
+            pre += num;
+            //累加出现相同余数的次数
+            count += map.getOrDefault((pre%modulo-k+modulo)%modulo,0);
+            //将当前出现的余数+1保存
+            map.put(pre%modulo,map.getOrDefault(pre%modulo,0)+1);
+        }
+
+        return count;
+    }
+}

+ 56 - 0
src/weekContest/A399/A1/Solution.java

@@ -0,0 +1,56 @@
+package weekContest.A399.A1;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/find-the-number-of-good-pairs-i/description/'>100323. 优质数对的总数 I</a>
+ * @ProjectName:  LeetCode
+ * @FileName: Solution
+ * @author: 杨逸
+ * @data:2024/5/26 10:14
+ * @description:
+ * 给你两个整数数组 nums1 和 nums2,长度分别为 n 和 m。同时给你一个正整数 k。
+ *
+ * 如果 nums1[i] 可以被 nums2[j] * k 整除,则称数对 (i, j) 为 优质数对(0 <= i <= n - 1, 0 <= j <= m - 1)。
+ *
+ * 返回 优质数对 的总数。
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:nums1 = [1,3,4], nums2 = [1,3,4], k = 1
+ *
+ * 输出:5
+ *
+ * 解释:
+ *
+ * 5个优质数对分别是 (0, 0), (1, 0), (1, 1), (2, 0), 和 (2, 2)。
+ *
+ * 示例 2:
+ *
+ * 输入:nums1 = [1,2,4,12], nums2 = [2,4], k = 3
+ *
+ * 输出:2
+ *
+ * 解释:
+ *
+ * 2个优质数对分别是 (3, 0) 和 (3, 1)。
+ *
+ *
+ *
+ * 提示:
+ *
+ * 1 <= n, m <= 50
+ * 1 <= nums1[i], nums2[j] <= 50
+ * 1 <= k <= 50
+ */
+public class Solution {
+    public int numberOfPairs(int[] nums1, int[] nums2, int k) {
+    int count = 0;
+        for (int i = 0; i < nums1.length; i++) {
+            for (int j = 0; j < nums2.length; j++) {
+                if (nums1[i]%(nums2[j]*k) == 0)count++;
+            }
+        }
+    return count;
+    }
+}

+ 24 - 0
src/weekContest/A399/A1/SolutionTest.java

@@ -0,0 +1,24 @@
+package weekContest.A399.A1;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/5/26 10:34
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void numberOfPairs() {
+        Solution solution = new Solution();
+
+        int[] nums1 = {1,3,4};
+        int[] nums2 = {1,3,4};
+        System.out.println("solution.numberOfPairs(nums1,nums2) = " + solution.numberOfPairs(nums1, nums2,1));
+    }
+}

+ 68 - 0
src/weekContest/A399/A2/Solution.java

@@ -0,0 +1,68 @@
+package weekContest.A399.A2;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/string-compression-iii/description/'>压缩字符串 III</a>
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/5/26 10:26
+ * @Description:
+ * 给你一个字符串 word,请你使用以下算法进行压缩:
+ *
+ * 从空字符串 comp 开始。当 word 不为空 时,执行以下操作:
+ * 移除 word 的最长单字符前缀,该前缀由单一字符 c 重复多次组成,且该前缀长度 最多 为 9 。
+ * 将前缀的长度和字符 c 追加到 comp 。
+ * 返回字符串 comp 。
+ *
+ *
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:word = "abcde"
+ *
+ * 输出:"1a1b1c1d1e"
+ *
+ * 解释:
+ *
+ * 初始时,comp = "" 。进行 5 次操作,每次操作分别选择 "a"、"b"、"c"、"d" 和 "e" 作为前缀。
+ *
+ * 对每个前缀,将 "1" 和对应的字符追加到 comp。
+ *
+ * 示例 2:
+ *
+ * 输入:word = "aaaaaaaaaaaaaabb"
+ *
+ * 输出:"9a5a2b"
+ *
+ * 解释:
+ *
+ * 初始时,comp = ""。进行 3 次操作,每次操作分别选择 "aaaaaaaaa"、"aaaaa" 和 "bb" 作为前缀。
+ *
+ * 对于前缀 "aaaaaaaaa",将 "9" 和 "a" 追加到 comp。
+ * 对于前缀 "aaaaa",将 "5" 和 "a" 追加到 comp。
+ * 对于前缀 "bb",将 "2" 和 "b" 追加到 comp。
+ *
+ *
+ * 提示:
+ *
+ * 1 <= word.length <= 2 * 105
+ * word 仅由小写英文字母组成。
+ */
+public class Solution {
+    public String compressedString(String word) {
+        String comp = "";
+        for (int i = 0; i < word.length(); i++) {
+            int count = 1;
+            char c = word.charAt(i);
+            while (i+1 < word.length() && c == word.charAt(i+1)){
+                count++;
+                i++;
+                if (count == 9)break;
+            }
+            comp += String.valueOf(count) + String.valueOf(c);
+        }
+        return comp;
+    }
+}

+ 27 - 0
src/weekContest/A399/A2/SolutionTest.java

@@ -0,0 +1,27 @@
+package weekContest.A399.A2;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/5/26 10:43
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void compressedString() {
+        Solution solution = new Solution();
+        String word = "abcde";
+        String result = solution.compressedString(word);
+        System.out.println("solution.compressedString(word) = " + result);
+        assertEquals(result,"1a1b1c1d1e");
+        word = "aaaaaaaaaaaaaabb";
+        result = solution.compressedString(word);
+        assertEquals(result,"9a5a2b");
+    }
+}

+ 115 - 0
src/weekContest/A399/A3/Solution.java

@@ -0,0 +1,115 @@
+package weekContest.A399.A3;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/find-the-number-of-good-pairs-ii/description/'>100321. 优质数对的总数 II</a>
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/5/26 10:26
+ * @Description:
+ * 给你两个整数数组 nums1 和 nums2,长度分别为 n 和 m。同时给你一个正整数 k。
+ *
+ * 如果 nums1[i] 可以被 nums2[j] * k 整除,则称数对 (i, j) 为 优质数对(0 <= i <= n - 1, 0 <= j <= m - 1)。
+ *
+ * 返回 优质数对 的总数。
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:nums1 = [1,3,4], nums2 = [1,3,4], k = 1
+ *
+ * 输出:5
+ *
+ * 解释:
+ *
+ * 5个优质数对分别是 (0, 0), (1, 0), (1, 1), (2, 0), 和 (2, 2)。
+ *
+ * 示例 2:
+ *
+ * 输入:nums1 = [1,2,4,12], nums2 = [2,4], k = 3
+ *
+ * 输出:2
+ *
+ * 解释:
+ *
+ * 2个优质数对分别是 (3, 0) 和 (3, 1)。
+ *
+ *
+ *
+ * 提示:
+ *
+ * 1 <= n, m <= 105
+ * 1 <= nums1[i], nums2[j] <= 106
+ * 1 <= k <= 103
+ */
+public class Solution {
+    public long numberOfPairs(int[] nums1, int[] nums2, int k) {
+        //同时能整除k和nums[j],才能整除k*nums[j]
+        long result = 0;
+        HashMap<Integer, Integer> map1 = new HashMap<>();
+        HashMap<Integer, Integer> map2 = new HashMap<>();
+        HashMap<Integer, Integer> map3 = new HashMap<>();
+
+        //筛选能整除k的nums[i]
+        ArrayList<Integer> list = new ArrayList<>();
+        for (int v : nums1) {
+            if (v%k==0)list.add(v);
+        }
+
+        for (Integer v : list) {
+            map1.put(v, map1.getOrDefault(v, 0) + 1);
+        }
+
+        for (int v : nums2) {
+            v = v*k;
+            //map2.put(v, map2.getOrDefault(v, 0) + 1);
+            if (v%2!=0){
+                //奇数
+                map2.put(v, map2.getOrDefault(v, 0) + 1);
+            }else {
+                //偶数
+                map3.put(v, map3.getOrDefault(v, 0) + 1);
+            }
+
+        }
+
+        for (Integer v1 : map1.keySet()) {
+
+            //for (Integer v2 : map2.keySet()) {
+            //    if (v1%v2==0)result+=(map1.get(v1)*map2.get(v2));
+            //}
+            if (v1%2!=0){
+                //奇数
+                for (Integer v2 : map2.keySet()) {
+                    if (v1%v2==0)result+=(map1.get(v1)*map2.get(v2));
+                }
+                //特殊的5和1
+                if (v1%5==0){
+                    for (Integer v2 : map3.keySet()) {
+                        if (v1%v2==0)result+=(map1.get(v1)*map3.get(v2));
+                    }
+                }
+            }else {
+                //偶数
+                for (Integer v2 : map3.keySet()) {
+                    if (v1%v2==0)result+=(map1.get(v1)*map3.get(v2));
+                }
+
+                //特殊的1
+                Integer aDefault = map2.getOrDefault(1, 0);
+                if (aDefault !=0){
+                    for (Integer integer : map1.keySet()) {
+                        if (integer%2==0)result+=aDefault*map1.get(integer);
+                    }
+                }
+            }
+
+        }
+        return result;
+    }
+
+}

+ 37 - 0
src/weekContest/A399/A3/SolutionTest.java

@@ -0,0 +1,37 @@
+package weekContest.A399.A3;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/5/26 10:59
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void numberOfPairs() {
+        int[] nums1 = {1,3,4};
+        int[] nums2 = {1,3,4};
+        Solution solution = new Solution();
+
+        long number = solution.numberOfPairs(nums1, nums2, 1);
+        System.out.println("solution.numberOfPairs(nums1,nums2,1) = " + number);
+        assertEquals(number,5);
+
+        nums1 = new int[]{1,2,4,12};
+        nums2 = new int[]{2,4};
+
+        number = solution.numberOfPairs(nums1,nums2,3);
+        assertEquals(number,2);
+
+        nums1 = new int[]{12,4};
+        nums2 = new int[]{1,4};
+        number = solution.numberOfPairs(nums1,nums2,3);
+        assertEquals(number,2);
+    }
+}

+ 56 - 0
src/weekContest/A399/A4/Solution.java

@@ -0,0 +1,56 @@
+package weekContest.A399.A4;
+
+/**
+ * @see <a href='https://leetcode.cn/problems/maximum-sum-of-subsequence-with-non-adjacent-elements/'>100306. 不包含相邻元素的子序列的最大和</a>
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/5/26 10:26
+ * @Description:
+ * 给你一个整数数组 nums 和一个二维数组 queries,其中 queries[i] = [posi, xi]。
+ *
+ * 对于每个查询 i,首先将 nums[posi] 设置为 xi,然后计算查询 i 的答案,该答案为 nums 中 不包含相邻元素 的子序列的 最大 和。
+ *
+ * 返回所有查询的答案之和。
+ *
+ * 由于最终答案可能非常大,返回其对 109 + 7 取余 的结果。
+ *
+ * 子序列 是指从另一个数组中删除一些或不删除元素而不改变剩余元素顺序得到的数组。
+ *
+ *
+ *
+ * 示例 1:
+ *
+ * 输入:nums = [3,5,9], queries = [[1,-2],[0,-3]]
+ *
+ * 输出:21
+ *
+ * 解释:
+ * 执行第 1 个查询后,nums = [3,-2,9],不包含相邻元素的子序列的最大和为 3 + 9 = 12。
+ * 执行第 2 个查询后,nums = [-3,-2,9],不包含相邻元素的子序列的最大和为 9 。
+ *
+ * 示例 2:
+ *
+ * 输入:nums = [0,-1], queries = [[0,-5]]
+ *
+ * 输出:0
+ *
+ * 解释:
+ * 执行第 1 个查询后,nums = [-5,-1],不包含相邻元素的子序列的最大和为 0(选择空子序列)。
+ *
+ *
+ *
+ * 提示:
+ *
+ * 1 <= nums.length <= 5 * 104
+ * -105 <= nums[i] <= 105
+ * 1 <= queries.length <= 5 * 104
+ * queries[i] == [posi, xi]
+ * 0 <= posi <= nums.length - 1
+ * -105 <= xi <= 105
+ */
+public class Solution {
+    public int maximumSumSubsequence(int[] nums, int[][] queries) {
+        return 0;
+    }
+}

+ 26 - 0
src/weekContest/A400/A1/Solution.java

@@ -0,0 +1,26 @@
+package weekContest.A400.A1;
+
+import java.util.Stack;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/6/2 10:18
+ * @Description:
+ */
+public class Solution {
+    public int minimumChairs(String s) {
+        int count = 0;
+        int ans = Integer.MIN_VALUE;
+        for (int i = 0; i < s.length(); i++) {
+            if (s.charAt(i)=='E') {
+                count++;
+            }else {
+                count--;
+            }
+            if (count>ans)ans=count;
+        }
+        return ans;
+    }
+}

+ 21 - 0
src/weekContest/A400/A1/SolutionTest.java

@@ -0,0 +1,21 @@
+package weekContest.A400.A1;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/6/2 10:33
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void minimumChairs() {
+        Solution solution = new Solution();
+
+    }
+}

+ 38 - 0
src/weekContest/A400/A2/Solution.java

@@ -0,0 +1,38 @@
+package weekContest.A400.A2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/6/2 10:18
+ * @Description:
+ */
+public class Solution {
+    public int countDays(int days, int[][] meetings) {
+        Arrays.sort(meetings, (a, b) -> {
+            if (a[0] > b[0]){
+                return 1;
+            }else if (a[0] > b[0] && a[1] < b[1]){
+                return 1;
+            }
+            return a[0] - b[0];
+        });
+        int endDay = 0;
+        int result = 0;
+        for (int[] meeting : meetings) {
+            if (meeting[0]<=endDay){
+                //连续的会议
+                endDay = Math.max(endDay,meeting[1]);
+            }else {
+                result+=meeting[0]-endDay-1;
+                endDay = meeting[1];
+            }
+        }
+        return result+=days-endDay;
+    }
+
+}

+ 46 - 0
src/weekContest/A400/A2/SolutionTest.java

@@ -0,0 +1,46 @@
+package weekContest.A400.A2;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/6/2 11:01
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void countDays() {
+        Solution solution = new Solution();
+
+        int days = 10;
+        int[][] meetings = {
+                {5,7},
+                {1,3},
+                {9,10}
+        };
+        int result = solution.countDays(days, meetings);
+        assertEquals(result,2);
+
+        days = 6;
+        meetings = new int[][]{
+                {1,6}
+        };
+        result = solution.countDays(days, meetings);
+        assertEquals(result,0);
+
+        days = 8;
+        meetings = new int[][]{
+                {3,4},
+                {4,8},
+                {2,5},
+                {3,8}
+        };
+        result = solution.countDays(days, meetings);
+        assertEquals(result,1);
+    }
+}

+ 75 - 0
src/weekContest/A400/A3/Solution.java

@@ -0,0 +1,75 @@
+package weekContest.A400.A3;
+
+import java.util.PriorityQueue;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/6/2 10:18
+ * @Description:
+ */
+public class Solution {
+    public String clearStars(String s) {
+        int[] flag = new int[s.length()];
+        PriorityQueue<Node> priorityQueue = new PriorityQueue<>((a,b)->a.v-b.v);
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            if (c=='*'){
+                flag[i]=1;
+                Node node = priorityQueue.poll();
+                flag[node.index]=1;
+            }else {
+                Node node = new Node(c, i);
+                priorityQueue.add(node);
+            }
+        }
+
+        StringBuilder ans = new StringBuilder();
+        for (int i = 0; i < flag.length; i++) {
+            if (flag[i]==0)ans.append(s.charAt(i));
+        }
+        return ans.toString();
+    }
+
+    private String t(String s){
+        int[] flag = new int[s.length()];
+        for (int i = s.length()-1; i >= 0; i--) {
+            if (s.charAt(i)=='*') {
+                flag[i] = 1;
+                int min = 'z'+1;
+                int index = i-1;
+                for (int j = i-1;j>= 0;j--){
+                    char c = s.charAt(j);
+                    if (c=='*' || flag[j]==1)continue;
+                    if (c<min){
+                        index = j;
+                        min = c;
+                    }
+                    if (c=='a')break;
+                }
+                flag[index]=1;
+            }
+        }
+
+        StringBuilder ans = new StringBuilder();
+        for (int i = 0; i < flag.length; i++) {
+            if (flag[i]==0)ans.append(s.charAt(i));
+        }
+        return ans.toString();
+    }
+    class Node implements Comparable{
+        int v;
+        int index;
+
+        public Node(int v, int index) {
+            this.v = v;
+            this.index = index;
+        }
+
+        @Override
+        public int compareTo(Object o) {
+            return this.v - ((Node) o).v;
+        }
+    }
+}

+ 36 - 0
src/weekContest/A400/A3/SolutionTest.java

@@ -0,0 +1,36 @@
+package weekContest.A400.A3;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: SolutionTest
+ * @Author: 杨逸
+ * @Data:2024/6/2 10:49
+ * @Description:
+ */
+public class SolutionTest {
+
+    @Test
+    public void clearStars() {
+        Solution solution = new Solution();
+
+        String s = "aab";
+        String result = solution.clearStars(s);
+        assertEquals(result,"aab");
+
+        s = "abc";
+        result = solution.clearStars(s);
+        assertEquals(result,"abc");
+
+        s = "d*o*";
+        result = solution.clearStars(s);
+        assertEquals(result,"");
+
+        s = "dk**";
+        result = solution.clearStars(s);
+        assertEquals(result,"");
+    }
+}

+ 11 - 0
src/weekContest/A400/A4/Solution.java

@@ -0,0 +1,11 @@
+package weekContest.A400.A4;
+
+/**
+ * @ProjectName: LeetCode
+ * @FileName: Solution
+ * @Author: 杨逸
+ * @Data:2024/6/2 10:18
+ * @Description: 
+ */
+public class Solution {
+}

+ 20 - 0
src/weekContest/B112/A1A2/Solution.java

@@ -0,0 +1,20 @@
+package weekContest.B112.A1A2;
+
+import java.util.Arrays;
+
+class Solution {
+    //canBeEqual
+    //checkStrings
+
+    static int count = 0;
+    public boolean checkStrings(String s1, String s2) {
+        //二维字符数组充当哈希表计数
+        char[][] c1 = new char[2][26],c2 = new char[2][26];
+        for (int i = 0; i < s1.length(); i++) {
+            c1[i%2][s1.charAt(i)-'a']++;
+            c2[i%2][s2.charAt(i)-'a']++;
+        }
+        //多维数组的比较
+        return Arrays.deepEquals(c1,c2);
+    }
+}

+ 31 - 0
src/weekContest/B112/A3/Solution.java

@@ -0,0 +1,31 @@
+package weekContest.B112.A3;
+
+import java.util.HashMap;
+import java.util.List;
+
+class Solution {
+    public long maxSum(List<Integer> nums, int m, int k) {
+        if (nums.size()<k)return 0;
+        //前缀和+哈希表+滑动窗口
+        long max = 0,cur = 0;
+        HashMap<Integer, Integer> map = new HashMap<>();
+        for (int i = 0; i < nums.size(); i++) {
+            Integer val = nums.get(i);
+            cur += val;
+            //统计目前出现的数值
+            map.put(val,map.getOrDefault(val,0)+1);
+            //计算最大值
+            if (i+1>=k && map.size()>=m)max = Math.max(max,cur);
+            //移除左边的数字
+            if (i+1>=k){
+                val = nums.get(i-k+1);
+                map.put(val,map.get(val)-1);
+                cur -= val;
+                if (map.get(val)==0)map.remove(val);
+            }
+        }
+
+
+        return max;
+    }
+}