結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2016-01-10 13:05:26 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 1,000 ms |
コード長 | 1,567 bytes |
コンパイル時間 | 842 ms |
コンパイル使用メモリ | 106,368 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-09-22 01:24:19 |
合計ジャッジ時間 | 2,322 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;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);elsem = 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 Scanstatic 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}