結果

問題 No.251 大きな桁の復習問題(1)
ユーザー fmhrfmhr
提出日時 2015-07-31 21:58:45
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 392 bytes
コンパイル時間 12,268 ms
コンパイル使用メモリ 230,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 03:15:03
合計ジャッジ時間 13,110 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	fmt.Println(pow(N,M))
}


// 繰り返し二乗法
// http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=NTL_1_B
// O(log(2)n)
const MOD = 129402307
func pow(x, n int)int{
	tmp := 1
	if n>0{
		tmp = pow(x, n/2)
		if n%2 ==0{
			tmp=(tmp*tmp)%MOD
		}else{
			tmp=(((tmp*tmp)%MOD)*x)%MOD
		}
	}
	return tmp
}
0