結果

問題 No.167 N^M mod 10
ユーザー mbanmban
提出日時 2016-12-31 08:24:27
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,173 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 105,728 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-05-09 14:28:43
合計ジャッジ時間 2,834 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
17,152 KB
testcase_01 AC 21 ms
17,152 KB
testcase_02 AC 27 ms
18,816 KB
testcase_03 AC 26 ms
18,944 KB
testcase_04 AC 23 ms
17,016 KB
testcase_05 AC 26 ms
19,072 KB
testcase_06 AC 22 ms
17,280 KB
testcase_07 AC 24 ms
17,024 KB
testcase_08 AC 26 ms
19,200 KB
testcase_09 AC 23 ms
17,152 KB
testcase_10 RE -
testcase_11 AC 26 ms
19,200 KB
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 26 ms
18,944 KB
testcase_16 AC 26 ms
19,200 KB
testcase_17 AC 22 ms
17,280 KB
testcase_18 AC 26 ms
18,816 KB
testcase_19 AC 26 ms
19,072 KB
testcase_20 AC 26 ms
18,816 KB
testcase_21 AC 22 ms
17,280 KB
testcase_22 AC 27 ms
18,816 KB
testcase_23 AC 26 ms
19,200 KB
testcase_24 AC 27 ms
18,944 KB
testcase_25 AC 26 ms
18,816 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 22 ms
17,136 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, 4);
                Console.WriteLine(myPow(n, m));
                break;

        }
        

        

    }
    static string myPow(int n,int m)
    {
        string s = Math.Pow(n, m).ToString();
        return s[s.Length - 1].ToString();
    }
   static int mod(string S,int M)
    {
        int N = int.Parse(S[S.Length - 2].ToString() + S[S.Length - 1]);
        if (M == 4)
        {
            return N % 4;
        }
        else
        {
            return -1;
        }
    }
}

0