結果
問題 |
No.2007 Arbitrary Mod (Easy)
|
ユーザー |
|
提出日時 | 2022-07-16 18:20:03 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 16,344 ms |
コンパイル使用メモリ | 233,236 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 18:15:29 |
合計ジャッジ時間 | 13,050 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var out = bufio.NewWriter(os.Stdout) func main() { buf := make([]byte, 1024*1024) sc.Buffer(buf, bufio.MaxScanTokenSize) sc.Split(bufio.ScanWords) a, n := nextInt(), nextInt() const m = 998244353 ans := Pow(a, n, m) PrintInt(m) PrintInt(ans) } func nextInt() int { sc.Scan() i, _ := strconv.Atoi(sc.Text()) return i } func PrintInt(x int) { defer out.Flush() fmt.Fprintln(out, x) } func Pow(x, y, p int) int { ret := 1 for y > 0 { if y%2 == 1 { ret = ret * x % p } y >>= 1 x = x * x % p } return ret }