結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
mban
|
| 提出日時 | 2016-12-31 08:31:41 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,105 bytes |
| コンパイル時間 | 1,029 ms |
| コンパイル使用メモリ | 105,600 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2024-12-16 04:21:45 |
| 合計ジャッジ時間 | 2,524 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 WA * 2 RE * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 = int.Parse(S[S.Length - 2].ToString() + S[S.Length - 1]);
return N % 4;
}
}
mban