結果
問題 |
No.442 和と積
|
ユーザー |
![]() |
提出日時 | 2020-10-27 07:16:08 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 888 bytes |
コンパイル時間 | 12,785 ms |
コンパイル使用メモリ | 226,796 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-21 21:50:41 |
合計ジャッジ時間 | 13,819 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) func gcd(x, y int) int { if x < y { x, y = y, x } for y > 0 { x, y = y, x%y } return x } func main() { defer flush() A := readInt() B := readInt() t := gcd(A+B, A) println(t * gcd((A+B)/t, B)) } const ( ioBufferSize = 1 * 1024 * 1024 // 1 MB ) var stdinScanner = func() *bufio.Scanner { result := bufio.NewScanner(os.Stdin) result.Buffer(make([]byte, ioBufferSize), ioBufferSize) result.Split(bufio.ScanWords) return result }() func readString() string { stdinScanner.Scan() return stdinScanner.Text() } func readInt() int { result, err := strconv.Atoi(readString()) if err != nil { panic(err) } return result } var stdoutWriter = bufio.NewWriter(os.Stdout) func flush() { stdoutWriter.Flush() } func println(args ...interface{}) (int, error) { return fmt.Fprintln(stdoutWriter, args...) }