[Solution] Sad Splits solution codechef

Sad Splits solution codechef – You are given a positive integer NN. You have to split each digit of NN into either of two non-empty subsequences AA or BB.

For example, if N=104N=104, some possible values of (A,B)(A,B) can be (10,4),(14,0)(10,4),(14,0) and (1,4)(1,4). Note that, after separating the digits into AA and BB, these subsequences are considered as positive integers and thus leading zeros can be omitted.

Sad Splits solution codechef

Let us define a function F(X,Y)=(X+Y)%2F(X,Y)=(X+Y)%2. Find out whether it is possible to find two non-empty subsequences AA and BB formed out of NN such that F(A,B)=0F(A,B)=0.

Input Format

  • First line will contain TT, number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, one integer NN.

Output Format

For each test case, print 𝚈𝙴𝚂YES if it is possible to find two non-empty subsequences AA and BB formed out of NN such that F(A,B)=0F(A,B)=0. Otherwise, print 𝙽𝙾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).

Sad Splits solution codechef

  • 1T10001≤T≤1000
  • 10N10910≤N≤109

Subtasks

  • Subtask 1 (100 points): Original constraints.

Sample Input 1 

2
10
73452

Sample Output 1 

NO
YES

Sad Splits solution codechef

Test Case 11: The only two possibilities are:

  • A=0,B=1A=0,B=1: Here F(A,B)=(A+B)%2=(0+1)%2=1%2=1F(A,B)=(A+B)%2=(0+1)%2=1%2=1.
  • A=1,B=0A=1,B=0: Here F(A,B)=(A+B)%2=(1+0)%2=1%2=1F(A,B)=(A+B)%2=(1+0)%2=1%2=1. Hence it’s not possible to achieve F(A,B)=0F(A,B)=0.

Test Case 22: One of the possible ways to split the digits of NN such that F(A,B)=0F(A,B)=0 is:

  • A=74,B=352A=74,B=352: Here F(A,B)=(A+B)%2=(74+352)%2=426%2=0F(A,B)=(A+B)%2=(74+352)%2=426%2=0.

For Solution

Click Here

Leave a Comment