結果

問題 No.2920 Blood Type
ユーザー 👑 KA37RI
提出日時 2024-08-12 14:24:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,546 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2024-08-12 14:27:19
合計ジャッジ時間 58,662 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import time
import random
import sys

# 開始時間
start = time.perf_counter()

# 入力
s = input().strip()
t = input().strip()

# 実行時間制限
time_limit = 2.0

# 変数の初期化
baby = {"A": 0, "B": 0, "O": 0, "AB": 0}
count = 0

# およそ(TL - 0.5)秒ループ
while time.perf_counter() - start < time_limit - 0.5:
	
	# 試行回数 += 1
	count += 1
	
	# ランダムに取り出す
	x = {random.choice(s), random.choice(t)}
	
	# 問題文中の判定
	if "A" in x and "B" not in x:
		baby["A"] += 1
	elif "B" in x and "A" not in x:
		baby["B"] += 1
	elif "A" in x and "B" in x:
		baby["AB"] += 1
	else:
		baby["O"] += 1
	
# 割合を百分率で計算(誤差対策の為0.5を足して切り捨て)
a = int(baby["A"] / count * 100 + 0.5)
b = int(baby["B"] / count * 100 + 0.5)
ab = int(baby["AB"] / count * 100 + 0.5)
o = int(baby["O"] / count * 100 + 0.5)

# 出力
print(a, b, ab, o)
print(count, baby, file=sys.stderr)
0