結果
問題 |
No.251 大きな桁の復習問題(1)
|
ユーザー |
![]() |
提出日時 | 2015-07-31 21:58:45 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 392 bytes |
コンパイル時間 | 13,404 ms |
コンパイル使用メモリ | 234,488 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 19:52:45 |
合計ジャッジ時間 | 13,269 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 14 |
ソースコード
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 }