No.3475 Many Hello Substrings
タグ : / 解いたユーザー数 59
作問者 : 👑
Problem Statement
Determine whether there exists a string $S$ satisfying all of the following conditions.
- $S$ is a string of length $N$ consisting of lowercase English letters.
- Let $T$ be the string obtained by concatenating $P$ copies of $S$. Then, $T$ contains exactly $K$ distinct occurrences of
helloas a substring.
You are given $T$ test cases; answer each of them.
Constraints
- All input values are integers
- $1 \leq T \leq 10^3$
- $1 \leq N \leq 10^8$
- $1 \leq P \leq 10^8$
- $0 \leq K \leq NP$
Input
The input is given from standard input in the following format. Here, $\mathrm{case}_i (1 \leq i \leq T)$ denotes the $i$-th test case.
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each case is given in the following format.
$N$ $P$ $K$
Output
Print $T$ lines. On the $i$-th line, print Yes if there exists a string $S$ satisfying the conditions in the $i$-th test case, and No otherwise.
Sample
Sample 1
Input
4 7 3 3 1 5 1 10 5 3 100 100 1000
Output
Yes No No Yes
For the $1$-st test case, if $S$ is helloab, for example, then $T$ is helloabhelloabhelloab. Since $T$ contains exactly $3$ occurrences of hello as a substring, the conditions are satisfied.
For the $2$-nd test case, no string $S$ satisfying the conditions exists. For example, if $S$ is a, then $T$ is aaaaa, but $T$ does not contain hello as a substring.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。