結果

問題 No.167 N^M mod 10
ユーザー しらゆきしらゆき
提出日時 2016-01-10 13:05:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 1,000 ms
コード長 1,567 bytes
コンパイル時間 2,870 ms
コンパイル使用メモリ 110,708 KB
実行使用メモリ 25,344 KB
最終ジャッジ日時 2023-10-21 23:57:55
合計ジャッジ時間 2,959 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
24,368 KB
testcase_01 AC 23 ms
25,344 KB
testcase_02 AC 24 ms
25,312 KB
testcase_03 AC 23 ms
25,312 KB
testcase_04 AC 24 ms
25,312 KB
testcase_05 AC 23 ms
25,344 KB
testcase_06 AC 23 ms
25,344 KB
testcase_07 AC 25 ms
25,276 KB
testcase_08 AC 24 ms
25,344 KB
testcase_09 AC 24 ms
25,344 KB
testcase_10 AC 23 ms
25,340 KB
testcase_11 AC 24 ms
25,344 KB
testcase_12 AC 23 ms
25,340 KB
testcase_13 AC 23 ms
25,344 KB
testcase_14 AC 21 ms
23,744 KB
testcase_15 AC 22 ms
25,344 KB
testcase_16 AC 23 ms
25,344 KB
testcase_17 AC 24 ms
25,280 KB
testcase_18 AC 23 ms
25,344 KB
testcase_19 AC 23 ms
25,344 KB
testcase_20 AC 23 ms
25,344 KB
testcase_21 AC 23 ms
25,344 KB
testcase_22 AC 26 ms
25,312 KB
testcase_23 AC 24 ms
25,312 KB
testcase_24 AC 24 ms
25,312 KB
testcase_25 AC 22 ms
25,312 KB
testcase_26 AC 21 ms
23,744 KB
testcase_27 AC 23 ms
25,312 KB
testcase_28 AC 22 ms
24,348 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.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var N = rs();
        var M = rs();

        var n = int.Parse(N[N.Length - 1].ToString());
        int m;
        if (M.Length == 1)
            m = int.Parse(M);
        else
            m = int.Parse(M[M.Length - 2].ToString() + M[M.Length - 1]);

        if (m == 0 && M.Length == 1)
        {
            Console.WriteLine(1);
            return;
        }

        m %= 4;

        if (m == 0) m += 4;

        Console.WriteLine(Math.Pow(n, m) % 10);
    }

    #region Scan
    static int ri() { return int.Parse(Console.ReadLine()); }
    static long rl() { return long.Parse(Console.ReadLine()); }
    static double rd() { return double.Parse(Console.ReadLine()); }
    static string rs() { return Console.ReadLine(); }
    static int[] ria() { return Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); }
    static long[] rla() { return Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
    static double[] rda() { return Console.ReadLine().Trim().Split().Select(double.Parse).ToArray(); }
    static string[] rsa() { return Console.ReadLine().Trim().Split(); }
    static void mul(out int a, out int b) { var arr = ria(); a = arr[0]; b = arr[1]; }
    public void mul(out int a, out int b, out int c) { var arr = ria(); a = arr[0]; b = arr[1]; c = arr[2]; }
    public void mul(out int a, out int b, out int c, out int d) { var arr = ria(); a = arr[0]; b = arr[1]; c = arr[2]; d = arr[3]; }
    #endregion
}
0