結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,132 KB
testcase_01 AC 32 ms
10,132 KB
testcase_02 AC 29 ms
10,132 KB
testcase_03 AC 30 ms
10,132 KB
testcase_04 AC 29 ms
10,132 KB
testcase_05 RE -
testcase_06 AC 29 ms
10,132 KB
testcase_07 AC 29 ms
10,132 KB
testcase_08 AC 30 ms
10,132 KB
testcase_09 AC 30 ms
10,132 KB
testcase_10 AC 29 ms
10,132 KB
testcase_11 AC 30 ms
10,132 KB
testcase_12 AC 29 ms
10,132 KB
testcase_13 AC 30 ms
10,132 KB
testcase_14 AC 29 ms
10,132 KB
testcase_15 AC 30 ms
10,132 KB
testcase_16 AC 28 ms
10,132 KB
testcase_17 AC 30 ms
10,132 KB
testcase_18 AC 29 ms
10,132 KB
testcase_19 AC 30 ms
10,132 KB
testcase_20 AC 29 ms
10,132 KB
testcase_21 AC 30 ms
10,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:10: 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 <= -9:
    return None
  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