判断元素是否存在

GitHub跳转原题关系图返回列表

本地题面缓存已迁移,解析内容待补充。

OJ: noi_openjudge

题目 ID: ch0113-41

难度:未知

标签:python

日期: 2026-07-30 23:01

题意

完整题面见同目录的 problem.md

思路

代码

Python代码

python
from collections import deque

start, target = map(int, input().split(","))
reachable = {start}
queue = deque([start])

while queue:
    value = queue.popleft()
    for next_value in (2 * value + 1, 3 * value + 1):
        if next_value <= target and next_value not in reachable:
            reachable.add(next_value)
            queue.append(next_value)

print("YES" if target in reachable else "NO")

复杂度

总结