結果

問題 No.63 ポッキーゲーム
ユーザー yo-kondoyo-kondo
提出日時 2018-03-10 21:10:39
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 13,059 ms
コンパイル使用メモリ 226,560 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 18:27:21
合計ジャッジ時間 12,122 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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)
}
0