CF BUDDY
← Problems·

1950D · Product of Binary Decimals

1100 · brute force, dp, implementation

Problem: Let's call a number a binary decimal if it is a positive integer and all digits in its decimal notation are either 00 or 11. For example, 10101111\,010\,111 is a binary decimal, while 1020110\,201 and 787788787\,788 are not.

Given a number nn, you are asked whether or not it is possible to represent nn as a product of some (not necessarily distinct) binary decimals.

Input Format: The first line contains a single integer tt (1t51041 \leq t \leq 5 \cdot 10^4) — the number of test cases.

The only line of each test case contains a single integer nn (1n1051 \leq n \leq 10^5).

Output Format: For each test case, output "YES" (without quotes) if nn can be represented as a product of binary decimals, and "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, strings "yES", "yes", and "Yes" will be recognized as a positive response).

Note: The first five test cases can be represented as a product of binary decimals as follows:

  • 121=11×11121 = 11 \times 11.
  • 1=11 = 1 is already a binary decimal.
  • 14641=11×11×11×1114\,641 = 11 \times 11 \times 11 \times 11.
  • 12221=11×11×10112\,221 = 11 \times 11 \times 101.
  • 10110=1011010\,110 = 10\,110 is already a binary decimal.

Sample Cases

Case 1

Input

11
121
1
14641
12221
10110
100000
99
112
2024
12421
1001

Output

YES
YES
YES
YES
YES
YES
NO
NO
NO
NO
YES

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback