結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
tnoda_
|
| 提出日時 | 2015-04-02 16:09:29 |
| 言語 | Go (1.26.1) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 1,000 ms |
| コード長 | 335 bytes |
| 記録 | |
| コンパイル時間 | 10,223 ms |
| コンパイル使用メモリ | 287,832 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-10 06:36:51 |
| 合計ジャッジ時間 | 11,473 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
package main
import (
"fmt"
"strconv"
)
func mod4(s string) int {
l := len(s)
if l > 2 {
s = s[l-2:]
}
x, _ := strconv.Atoi(s)
return x % 4
}
func main() {
var N, M string
fmt.Scan(&N, &M)
n := int(N[len(N)-1] - '0')
x := 1
for i := 0; i < mod4(M)+4; i++ {
x *= n
}
if M == "0" {
x = 1
}
fmt.Println(x % 10)
}
tnoda_