#C11267. Palindromic Numbers in Decimal and Binary
Palindromic Numbers in Decimal and Binary
Palindromic Numbers in Decimal and Binary
You are given a list of non-negative integer numbers. For each number, check whether both its decimal representation and its binary representation (without the '0b' prefix) are palindromic.
A string is palindromic if it reads the same from left to right and right to left. For example, the number 585
has a decimal representation "585" which is a palindrome; its binary representation is "1001001001", which is also a palindrome. Thus, for 585
the answer is "Yes".
Formally, given an integer \(n\), let \(D(n)\) be the string representation of \(n\) in base 10 and \(B(n)\) be the representation of \(n\) in base 2 (without the prefix). You should output "Yes" if both \(D(n) = reverse(D(n))\) and \(B(n) = reverse(B(n))\). Otherwise, output "No".
inputFormat
The first line of input contains an integer \(T\) denoting the number of test cases. Each of the following \(T\) lines contains one non-negative integer \(n\).
Constraints:
- \(1 \leq T \leq 10^5\)
- \(0 \leq n \leq 10^9\)
outputFormat
For each test case, output a single line containing "Yes" if both the decimal and binary representations of the number are palindromic, otherwise output "No".
## sample5
585
5
21
65
217
Yes
Yes
No
No
No
</p>