結果

問題 No.167 N^M mod 10
ユーザー mbanmban
提出日時 2016-12-31 08:32:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 104,840 KB
実行使用メモリ 25,232 KB
最終ジャッジ日時 2023-08-22 08:49:03
合計ジャッジ時間 5,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
20,544 KB
testcase_01 AC 48 ms
20,480 KB
testcase_02 AC 62 ms
25,112 KB
testcase_03 AC 60 ms
23,220 KB
testcase_04 AC 49 ms
20,448 KB
testcase_05 AC 60 ms
23,180 KB
testcase_06 AC 49 ms
20,432 KB
testcase_07 AC 48 ms
22,592 KB
testcase_08 AC 60 ms
25,012 KB
testcase_09 AC 48 ms
18,320 KB
testcase_10 AC 60 ms
25,196 KB
testcase_11 AC 59 ms
23,124 KB
testcase_12 AC 59 ms
22,816 KB
testcase_13 AC 59 ms
23,196 KB
testcase_14 WA -
testcase_15 AC 59 ms
22,900 KB
testcase_16 AC 59 ms
25,232 KB
testcase_17 AC 48 ms
22,528 KB
testcase_18 AC 59 ms
22,892 KB
testcase_19 AC 59 ms
23,168 KB
testcase_20 AC 59 ms
24,976 KB
testcase_21 AC 49 ms
22,572 KB
testcase_22 AC 61 ms
23,144 KB
testcase_23 AC 60 ms
22,856 KB
testcase_24 AC 61 ms
25,200 KB
testcase_25 AC 60 ms
25,152 KB
testcase_26 WA -
testcase_27 AC 60 ms
23,180 KB
testcase_28 AC 49 ms
20,392 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static void Main()
    {
        string N = Console.ReadLine();
        string M = Console.ReadLine();
        char NLast = N[N.Length - 1];
        char MLast = M[M.Length - 1];
        switch (NLast)
        {
            case '0':
            case '1':
            case '5':
            case '6':
                Console.WriteLine(NLast);
                break;
            default:
                int n = int.Parse(NLast.ToString());
                int m = mod(M);
                Console.WriteLine(myPow(n, m));
                break;

        }
    }
    static string myPow(int n, int m)
    {
        if (m == 0)
        {
            m = 4;
        }
        string s = Math.Pow(n, m).ToString();
        return s[s.Length - 1].ToString();
    }
    static int mod(string S)
    {

        int N = S.Length>=2?int.Parse(S[S.Length - 2].ToString() + S[S.Length - 1]):int.Parse(S);
        return N % 4;
    }
}

0