問題一覧 > 通常問題

No.3455 N-beatsu

レベル : / AI推定難易度 : 124 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 118
作問者 : t5ugu / テスター : dyktr_06 くらげ おのせ hikikomori tyawanmusi
お気に入りにしたユーザー ProblemId : 13042 / 自分の提出
問題文最終更新日: 2026-02-27 23:43:56
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
MMA Contest 021 (順位表) の他の問題:

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.

  1. $X$ is a multiple of $N$
  2. $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もしくは右上の雲マークをクリックしてアカウントを作成してください。