P21328 [CodeChef] PINBS
普及
题目描述

You are given a binary string S of length N. Your task is to check if there exists a [substring] of S which is the binary representation of a [prime number].

Formally, check if there exist integers L and R such that 1 ≤ L ≤ R ≤ N, and the substring $S_{L} S_{L+1} S_{L+2} \ldots S_{R}$, when treated as a binary integer, is prime.

Print "Yes" if such a substring exists, and "No" if it doesn't.

------ Input Format ------

  • The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
  • Each testcase consists of a single line of input, containing a binary string S.

------ Output Format ------

For each test case, output a single line containing one string — "Yes" or "No", the answer to the problem.

You may print each character of the answer in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).

------ Constraints ------

$1 ≤ T ≤ 2.5 \cdot 10^{4}$
$|S| ≤ 10^{5}$
- The sum of $|S|$ over all tests does not exceed $3 \cdot 10^{5}$

------ subtasks ------

Subtask 1 (30 points):
$1 ≤ T ≤ 10^{3}$
$|S| ≤ 10$

Subtask 2 (70 points):
Original constraints

----- Sample Input 1 ------
3
1
111
101101
----- Sample Output 1 ------
No
Yes
Yes
----- explanation 1 ------
Test case $1$: There is only one substring, namely "1", and it isn't prime.

Test case $2$: The substrings of the given string are $\{$"1", "11", "111", "1", "11", "1"$\}$. Of these, "111" which represents $7$ in binary, and "11" which represents $3$ in binary, are primes.

Test case $3$: One of the substrings of the string is "1101", which is the binary representation of $13$ — a prime.

输入格式

见题面

输出格式

见题面

样例输入
3 1 111 101101
样例输出
No Yes Yes