結果

問題 No.167 N^M mod 10
ユーザー parukiparuki
提出日時 2016-09-07 01:05:59
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 545 bytes
コンパイル時間 10,793 ms
コンパイル使用メモリ 232,532 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 17:03:43
合計ジャッジ時間 11,826 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 10 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 10 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 12 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main
import (
    "fmt"
    "math/big"
)

func pow(x, y *big.Int) int{
    x = x.Mod(x, big.NewInt(10))
    xx := int(x.Uint64())
    zero := big.NewInt(0)
    z := 1
    for ; y.Cmp(zero) != 0 ; {
        if y.Bit(0) == 1 {
            z = z * xx % 10
        }
        xx = xx * xx % 10
        y = y.Rsh(y, 1)
    }
    return z
}

func main() {

    var sx, sy string
    fmt.Scanf("%s%s",&sx, &sy)
    x := big.NewInt(1)
    y := big.NewInt(1)
    x.SetString(sx, 10)
    y.SetString(sy, 10)
    z := pow(x, y)
    fmt.Println(z)
}
0