結果

問題 No.63 ポッキーゲーム
ユーザー R NR N
提出日時 2020-07-22 22:52:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 859 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 8,000 KB
最終ジャッジ日時 2023-09-05 03:08:01
合計ジャッジ時間 1,753 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,764 KB
testcase_01 AC 15 ms
7,832 KB
testcase_02 AC 16 ms
7,808 KB
testcase_03 AC 15 ms
7,968 KB
testcase_04 AC 15 ms
7,768 KB
testcase_05 AC 15 ms
7,816 KB
testcase_06 AC 16 ms
7,804 KB
testcase_07 AC 15 ms
7,824 KB
testcase_08 AC 16 ms
7,908 KB
testcase_09 AC 15 ms
7,848 KB
testcase_10 AC 16 ms
7,848 KB
testcase_11 AC 15 ms
8,000 KB
testcase_12 AC 14 ms
7,800 KB
testcase_13 AC 15 ms
7,796 KB
testcase_14 AC 15 ms
7,896 KB
testcase_15 AC 15 ms
7,820 KB
testcase_16 AC 15 ms
7,972 KB
testcase_17 AC 14 ms
7,800 KB
testcase_18 AC 15 ms
7,800 KB
testcase_19 AC 14 ms
7,840 KB
testcase_20 AC 15 ms
7,816 KB
testcase_21 AC 15 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8
# ポッキーの長さ
L, K = map(int, input().split())

# 2人でKずつ食べる
eat_L = 2 * K

# ポッキーの長さが偶数のときのK回数であまりがない場合
K_cnt1 = divmod(L, eat_L)
a_len1 = (K_cnt1[0] + 1) * K
b_len1 = (K_cnt1[0] - 1) * K

# ポッキーの長さが偶数のときのK回数であまりが生じる場合
K_cnt2 = divmod(L, eat_L)
a_len2 = K_cnt2[0] * K + L % eat_L
b_len2 = K_cnt2[0] * K

# ポッキーの長さが奇数のときのK回数
K_cnt3 = divmod(L, eat_L)
a_len3 = K_cnt3[0] * K + L % eat_L
b_len3 = K_cnt3[0] * K

# ここより問題に解答する
if L % 2 == 0 and L <= 2 * K:
    ans = 0
    print(ans)
elif L % 2 == 0 and L % eat_L == 0:
    ans = b_len1
    print(ans)
elif L % 2 == 0 and L % eat_L != 0:
    ans = b_len2
    print(ans)
elif L % 2 != 0:
    ans = b_len3
    print(ans)
0