結果

問題 No.167 N^M mod 10
ユーザー bluemeganebluemegane
提出日時 2020-09-10 11:02:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 103 ms / 1,000 ms
コード長 811 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 63,320 KB
実行使用メモリ 27,068 KB
最終ジャッジ日時 2023-08-24 13:53:28
合計ジャッジ時間 4,893 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,720 KB
testcase_01 AC 59 ms
20,732 KB
testcase_02 AC 102 ms
22,828 KB
testcase_03 AC 103 ms
24,840 KB
testcase_04 AC 103 ms
26,900 KB
testcase_05 AC 58 ms
20,768 KB
testcase_06 AC 58 ms
20,736 KB
testcase_07 AC 58 ms
20,772 KB
testcase_08 AC 60 ms
20,812 KB
testcase_09 AC 59 ms
22,804 KB
testcase_10 AC 58 ms
18,732 KB
testcase_11 AC 58 ms
20,804 KB
testcase_12 AC 58 ms
20,712 KB
testcase_13 AC 58 ms
20,696 KB
testcase_14 AC 56 ms
20,748 KB
testcase_15 AC 58 ms
20,816 KB
testcase_16 AC 59 ms
20,732 KB
testcase_17 AC 59 ms
20,872 KB
testcase_18 AC 59 ms
20,756 KB
testcase_19 AC 59 ms
20,760 KB
testcase_20 AC 60 ms
22,700 KB
testcase_21 AC 60 ms
24,800 KB
testcase_22 AC 101 ms
24,912 KB
testcase_23 AC 101 ms
24,804 KB
testcase_24 AC 101 ms
24,844 KB
testcase_25 AC 102 ms
27,068 KB
testcase_26 AC 58 ms
20,820 KB
testcase_27 AC 103 ms
24,904 KB
testcase_28 AC 100 ms
24,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Numerics;
using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        var n = s[s.Length - 1] - '0';
        BigInteger m2 = BigInteger.Parse(Console.ReadLine().Trim());
        if (m2 == 0) { Console.WriteLine(1); goto exit; }
        if (n == 0) { Console.WriteLine(0); goto exit; }
        var m3 = m2 % 4;
        var m = (int)m3;
        if (m == 0) m = 3;
        else m--;
        var map = makeMap();
        Console.WriteLine(map[n,m]);
    exit:;
    }
    static int[,] makeMap()
    {
        var map = new int[10, 4];
        for (int i = 0; i < 10; i++) map[i, 0] = i;
        for (int i = 0; i < 10; i++)
            for (int j = 1; j < 4; j++)
                map[i, j] = (map[i, j - 1] * i) % 10;
        return map;
    }
}
0