[Solution] Two Different Palindromes CodeChef Solution
Problem
You are given two positive integers and . You need to construct two different binary strings (i.e, they are strings which consist of only s and s), which satisfy these two conditions:
- Both the strings should be palindromes.
- Each string should have exactly s, and exactly s in them.
Output Yes
if two such different binary strings can be constructed and No
otherwise.
Note:
- A string is said to be a palindrome, if the string and the reverse of the string are identical.
- Two strings are said to be different if either their lengths are different, or if they differ in at least one character.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case contains two space-separated integers, and , in a new line.
Output Format
For each test case, output on a new line 'Yes', if you can construct two different binary strings satisfying the conditions. If not, output No
.
You may print each character of the string in uppercase or lowercase (for example, the strings YeS
, yes
, YES
, and YEs
will all be treated as identical).
Explanation:
Test case : Consider the binary strings and . Both of them are palindromes, and both of them have exactly s, and s. Hence we can construct them, and so the answer is Yes
.
Test case : Consider the binary strings and . Both of them are palindromes, and both of them have exactly s, and s. Hence we can construct them, and so the answer is Yes
.
Test case : There is no way to construct two such different strings. Hence the answer is No
.
No comments:
Post a Comment