4 条题解

  • 0
    @ 2024-1-7 13:35:53

    蒟蒻写法 记得开long

    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int x = sc.nextInt();
            int m = sc.nextInt();
            x %= 10;
            if(x == 1){
                System.out.println((long)m);
            }else if(x == 2){
                if(m >= 3){
                    System.out.println((long)m * 6);
                }else {
                    for (int i = 0; i < m - 1; i++) {
                        x *= x;
                    }
                    x %= 10;
                    System.out.println((long)x * m);
                }
            } else if (x == 3) {
                if(m >= 3){
                    System.out.println((long)m);
                }else {
                    for (int i = 0; i < m - 1; i++) {
                        x *= x;
                    }
                    x %= 10;
                    System.out.println((long)x * m);
                }
            } else if(x == 4){
                if(m >= 2){
                    System.out.println((long)m * 6);
                }else System.out.println((long)4 * m);
            }else if(x == 5){
                System.out.println((long)5 * m);
            }else if(x == 6){
                System.out.println((long) 6 * m);
            }else if(x == 7){
                if(m >= 3){
                    System.out.println((long)m);
                }else {
                    for (int i = 0; i < m - 1; i++) {
                        x *= x;
                    }
                    x %= 10;
                    System.out.println((long)x * m);
                }
            }else if(x == 8){
                if(m >= 3){
                    System.out.println((long)6 * m);
                }else {
                    for (int i = 0; i < m - 1; i++) {
                        x *= x;
                    }
                    x %= 10;
                    System.out.println((long)x * m);
                }
            }else if(x == 9){
                if(m >= 2){
                    System.out.println((long)m);
                }else {
                    System.out.println((long)9 * m);
                }
            }else System.out.println(0);
        }
    }
    

    信息

    ID
    587
    时间
    1000ms
    内存
    256MiB
    难度
    9
    标签
    递交数
    708
    已通过
    44
    上传者