結果

問題 No.825 賢いお買い物
ユーザー hang_hang_clnhang_hang_cln
提出日時 2019-05-27 21:58:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 463 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 11,872 KB
実行使用メモリ 10,192 KB
最終ジャッジ日時 2023-10-17 18:18:33
合計ジャッジ時間 1,670 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,128 KB
testcase_01 AC 33 ms
10,128 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 29 ms
10,128 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 AC 30 ms
10,128 KB
testcase_12 AC 30 ms
10,128 KB
testcase_13 AC 30 ms
10,128 KB
testcase_14 AC 30 ms
10,128 KB
testcase_15 AC 29 ms
10,128 KB
testcase_16 AC 28 ms
10,128 KB
testcase_17 AC 29 ms
10,128 KB
testcase_18 AC 29 ms
10,128 KB
testcase_19 AC 29 ms
10,128 KB
testcase_20 AC 30 ms
10,128 KB
testcase_21 AC 29 ms
10,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:9: SyntaxWarning: "is" with a literal. Did you mean "=="?
  return None if b is 0 else 1 + calc(a+9, b-1, coins) # 1Gの商品を10G払って購入

ソースコード

diff #

A, B, C = map(int, input().split())

# 複数回の会計に分割できる
def calc(a,b,coins):

  if a + b is coins:
    return 0
  elif a + b < coins:
    return None if b is 0 else 1 + calc(a+9, b-1, coins) # 1Gの商品を10G払って購入
  else:
    if a >= 11:
      return 1 + calc(a-11, b+1, coins) # 1Gの商品を11G払って購入
    return 1 + calc(a-1, b, coins) if a >= 1 else 10 + calc(a, b-1, coins)
      
print(calc(A, B, C) or "Impossible")
0