結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2020-09-10 11:02:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 73 ms / 1,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 905 ms |
コンパイル使用メモリ | 113,280 KB |
実行使用メモリ | 32,612 KB |
最終ジャッジ日時 | 2024-12-22 21:12:27 |
合計ジャッジ時間 | 2,991 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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; } }