No.3455 N-beatsu
タグ : / 解いたユーザー数 118
作問者 :
くらげ
hikikomori
Problem Statement
You are given a positive integer $N$ and $Q$ positive integers $X_i$.
Here, $X$ is defined to be an $N$-beatsu number if at least one of the following conditions holds.
- $X$ is a multiple of $N$
- $N$ is one of the contiguous substrings of $X$
On line $i\ (1 \le i \le Q)$, print Yes if $X_i$ is an $N$-beatsu number, and No otherwise.
Constraints
- $1 \le N \le 1000$
- $1 \le Q \le 5 \times 10^4$
- For each $i$ $(1 \le i \le Q)$, $1 \le X_i \le 2 \times 10^4$
- All inputs are integers
Input
$N$ $Q$ $X_1$ $X_2$ $\vdots$ $X_Q$
Output
On line $i$, print Yes if $X_i$ is an $N$-beatsu number, and No otherwise.
Print a newline at the end.
Sample
Sample 1
Input
10 4 1 20 100 101
Output
No Yes Yes Yes
To determine whether $X_i$ is a $10$-beatsu number, it suffices to check whether "$X_i$ is a multiple of $10$" or "$X_i$ contains $10$ as a contiguous substring".
$1$ is not a $10$-beatsu number.
$20$ is a multiple of $10$, so it is a $10$-beatsu number.
$100$ satisfies both conditions, so it is a $10$-beatsu number.
$101$ contains $10$ as a contiguous substring, so it is a $10$-beatsu number.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。