結果
問題 | No.63 ポッキーゲーム |
ユーザー |
|
提出日時 | 2018-03-10 21:10:39 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 11,891 ms |
コンパイル使用メモリ | 226,344 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-14 17:56:37 |
合計ジャッジ時間 | 12,313 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) // エントリポイント func main() { in := bufio.NewScanner(os.Stdin) // ポッキーの長さと、1回にかじるポッキーの長さ in.Scan() input1 := in.Text() fmt.Println(pocky(input1)) } func pocky(str string) string { sp := strings.Split(str, " ") // ポッキーの長さ pockyLength, _ := strconv.Atoi(sp[0]) // 1回に齧るポッキーの長さ gnawLength, _ := strconv.Atoi(sp[1]) res := pockyLength / (gnawLength * 2) if pockyLength % (gnawLength * 2) == 0 && res != 0 { // ちょうど割り切れた場合はかじるのをやめるため、-1 res-- } res *= gnawLength return strconv.Itoa(res) }