公式

A - 幸運の番号 / Lucky Number 解説 by admin 印刷ページ

swe-2-high

Whether the ticket wins depends only on whether 7 appears at least \(K\) times. The program scans each character of \(S\), incrementing a counter whenever it sees 7. After the scan it prints Yes if the count \(c\) is at least \(K\), and No otherwise. The scan counts every 7 exactly once with no omissions or duplicates, so the decision is correct. Each character is examined once, giving \(O(N)\) time; the string takes \(O(N)\) space and the counter uses only \(O(1)\) extra space.

投稿日時:
最終更新: