結果
| 問題 |
No.653 E869120 and Lucky Numbers
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:59:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,136 bytes |
| コンパイル時間 | 313 ms |
| コンパイル使用メモリ | 82,412 KB |
| 実行使用メモリ | 76,784 KB |
| 最終ジャッジ日時 | 2025-03-31 17:59:47 |
| 合計ジャッジ時間 | 2,787 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 6 |
ソースコード
p = input().strip()
reversed_p = p[::-1] # Process from least significant digit
# DP states are tuples (carry_in, a_has_non_zero, b_has_non_zero)
current_states = {(0, False, False)}
for digit in reversed_p:
current_digit = int(digit)
new_states = set()
for (carry_in, a_used, b_used) in current_states:
for a in [0, 6, 7]:
for b in [0, 6, 7]:
# Update whether a and b have non-zero digits
new_a_used = a_used or (a in (6, 7))
new_b_used = b_used or (b in (6, 7))
sum_total = a + b + carry_in
if sum_total % 10 == current_digit:
carry_out = sum_total // 10
new_state = (carry_out, new_a_used, new_b_used)
new_states.add(new_state)
current_states = new_states
if not current_states:
break # Early exit if no possible states
# Check if any valid state exists with no carry and both having non-zero digits
valid = any(carry == 0 and a_used and b_used for (carry, a_used, b_used) in current_states)
print("Yes" if valid else "No")
lam6er