結果

問題 No.23 技の選択
ユーザー yuma25689yuma25689
提出日時 2015-11-07 14:33:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 1,213 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 8,588 KB
最終ジャッジ日時 2023-09-11 02:19:30
合計ジャッジ時間 2,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,912 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 15 ms
7,824 KB
testcase_03 AC 29 ms
8,452 KB
testcase_04 AC 29 ms
8,476 KB
testcase_05 AC 28 ms
8,588 KB
testcase_06 AC 27 ms
8,500 KB
testcase_07 AC 21 ms
7,852 KB
testcase_08 AC 24 ms
8,204 KB
testcase_09 AC 29 ms
8,476 KB
testcase_10 AC 23 ms
7,912 KB
testcase_11 AC 16 ms
7,788 KB
testcase_12 AC 20 ms
7,788 KB
testcase_13 AC 27 ms
8,436 KB
testcase_14 AC 22 ms
7,824 KB
testcase_15 AC 24 ms
8,148 KB
testcase_16 AC 16 ms
7,856 KB
testcase_17 AC 21 ms
7,812 KB
testcase_18 AC 24 ms
8,256 KB
testcase_19 AC 26 ms
8,364 KB
testcase_20 AC 17 ms
7,812 KB
testcase_21 AC 17 ms
7,820 KB
testcase_22 AC 24 ms
7,836 KB
testcase_23 AC 18 ms
7,788 KB
testcase_24 AC 17 ms
7,828 KB
testcase_25 AC 26 ms
8,232 KB
testcase_26 AC 17 ms
7,912 KB
testcase_27 AC 27 ms
8,392 KB
testcase_28 AC 24 ms
8,208 KB
testcase_29 AC 25 ms
8,152 KB
testcase_30 AC 25 ms
8,168 KB
testcase_31 AC 25 ms
8,144 KB
testcase_32 AC 25 ms
8,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# H A D
# 一行に、敵の体力Hと通常攻撃のダメージ量A、必殺技のダメージ量Dが半角スペース区切りで与えられる。
# 1≤H,A,D≤10000

import sys

line=sys.stdin.readline()
line1=line.split()
enemyHP = int(line1[0])
normalDamage=int(line1[1])
criticalDamage=int(line1[2])

INF=10e9
# HPに対する最小期待回数の配列
HPandAttackCount=[INF for i in range(enemyHP+1)]

HPandAttackCount[0]=0;
for hp in range(1,enemyHP+1):
	# 計算済みでない場合のみ計算
	if HPandAttackCount[hp] != INF:
		continue

	# 現在ループ中のhpに対する対象の回数期待値を求める
	# 必殺技は、2/3回しか当たらないので、1.5回とみなせば良いらしい

	# 通常!
	if 0<=hp-normalDamage:
		HPandAttackCount[hp] = min(HPandAttackCount[hp], \
									HPandAttackCount[hp-normalDamage]+1.0 )
	else:
		HPandAttackCount[hp] = min(HPandAttackCount[hp], 1.0 )

	# 必殺!
	if 0<=hp-criticalDamage:
		HPandAttackCount[hp] = min(HPandAttackCount[hp], \
									HPandAttackCount[hp-criticalDamage]+1.5 )
	else:
		HPandAttackCount[hp] = min(HPandAttackCount[hp], 1.5 )

# for dp in HPandAttackCount:
# 	print(dp)

print( HPandAttackCount[enemyHP] )
0