Run ID:114663
提交时间:2025-03-22 21:06:12
import sys def find_nth_beautiful_number(n): def count(x): return x // 3 + x // 5 - x // 15 low = 1 high = 5 * n # 初始高值设为5倍的n,足够大以确保覆盖 ans = 0 while low <= high: mid = (low + high) // 2 cnt = count(mid) if cnt >= n: ans = mid high = mid - 1 else: low = mid + 1 return ans for line in sys.stdin: n = int(line.strip()) print(find_nth_beautiful_number(n))