1 条题解

  • 0
    @ 2023-9-23 13:40:48
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            final Scanner scanner = new Scanner(System.in);
            final StringBuilder result = new StringBuilder();
            final String in = scanner.nextLine() + "❤";
            int currentNumber = 47, size = 0;
            for (int i = 0; i < in.length(); i++) {
                int index = in.charAt(i);
                if (index != currentNumber) {
                    if (currentNumber != 47) {
                        result.append(size).append((char) currentNumber);
                    }
                    currentNumber = index;
                    size = 1;
                    continue;
                }
                size++;
            }
            System.out.println(result);
        }
    }
    
    • 1

    信息

    ID
    146
    时间
    1000ms
    内存
    128MiB
    难度
    4
    标签
    (无)
    递交数
    426
    已通过
    182
    上传者