Submission #20386462


Source Code Expand

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        long A = sc.nextLong() % 10;
        long B = sc.nextLong();
        long C = sc.nextLong();

        BigInteger bA = BigInteger.valueOf(A);// sc.nextBigInteger();
        BigInteger bB = BigInteger.valueOf(B);// sc.nextBigInteger();
        BigInteger bC = BigInteger.valueOf(C);// sc.nextBigInteger();

        if (A == 0) {
            System.out.println(0);
        } else if (A == 1) {
            System.out.println(1);
        } else if (A == 2) {
            BigInteger BC = bB.modPow(bC, BigInteger.valueOf(4));
            if (BC.equals(BigInteger.ZERO))
                BC = BigInteger.valueOf(4);
            BigInteger ABC = bA.modPow(BC, BigInteger.valueOf(10));
            System.out.println(ABC);
        } else if (A == 3) {
            BigInteger BC = bB.modPow(bC, BigInteger.valueOf(4));
            if (BC.equals(BigInteger.ZERO))
                BC = BigInteger.valueOf(4);
            BigInteger ABC = bA.modPow(BC, BigInteger.valueOf(10));
            System.out.println(ABC);
        } else if (A == 4) {
            BigInteger BC = bB.modPow(bC, BigInteger.valueOf(2));
            if (BC.equals(BigInteger.ZERO))
                BC = BigInteger.valueOf(2);
            BigInteger ABC = bA.modPow(BC, BigInteger.valueOf(10));
            System.out.println(ABC);
        } else if (A == 5) {
            System.out.println(5);
        } else if (A == 6) {
            System.out.println(6);
        } else if (A == 7) {
            BigInteger BC = bB.modPow(bC, BigInteger.valueOf(4));
            if (BC.equals(BigInteger.ZERO))
                BC = BigInteger.valueOf(4);
            BigInteger ABC = bA.modPow(BC, BigInteger.valueOf(10));
            System.out.println(ABC);
        } else if (A == 8) {
            BigInteger BC = bB.modPow(bC, BigInteger.valueOf(4));
            if (BC.equals(BigInteger.ZERO))
                BC = BigInteger.valueOf(4);
            BigInteger ABC = bA.modPow(BC, BigInteger.valueOf(10));
            System.out.println(ABC);
        } else if (A == 9) {
            BigInteger BC = bB.modPow(bC, BigInteger.valueOf(2));
            if (BC.equals(BigInteger.ZERO))
                BC = BigInteger.valueOf(2);
            BigInteger ABC = bA.modPow(BC, BigInteger.valueOf(10));
            System.out.println(ABC);
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}

Submission Info

Submission Time
Task B - A^B^C
User kametaro
Language Java (OpenJDK 11.0.6)
Score 400
Code Size 2990 Byte
Status AC
Exec Time 120 ms
Memory 36036 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 28
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 116 ms 35776 KiB
02.txt AC 105 ms 35832 KiB
03.txt AC 111 ms 35836 KiB
04.txt AC 114 ms 35768 KiB
05.txt AC 116 ms 35664 KiB
06.txt AC 120 ms 35956 KiB
07.txt AC 114 ms 35748 KiB
08.txt AC 113 ms 35792 KiB
09.txt AC 114 ms 35884 KiB
10.txt AC 110 ms 35892 KiB
11.txt AC 106 ms 36036 KiB
12.txt AC 110 ms 35748 KiB
13.txt AC 110 ms 35884 KiB
14.txt AC 115 ms 35876 KiB
15.txt AC 109 ms 35724 KiB
16.txt AC 104 ms 35832 KiB
17.txt AC 113 ms 35816 KiB
18.txt AC 112 ms 35860 KiB
19.txt AC 109 ms 35932 KiB
20.txt AC 106 ms 35936 KiB
21.txt AC 118 ms 35860 KiB
22.txt AC 118 ms 35720 KiB
23.txt AC 110 ms 35828 KiB
24.txt AC 117 ms 35868 KiB
25.txt AC 111 ms 35880 KiB
s1.txt AC 117 ms 35772 KiB
s2.txt AC 117 ms 35756 KiB
s3.txt AC 107 ms 35708 KiB