# [Solution] Alternating Work Days solution codechef

## Alternating Work Days solution codechef

Alice and Bob are two friends. Initially, the skill levels of them are zero. They work on alternative days, i.e one of Alice and Bob works on the odd-numbered days(1,3,5,)(1,3,5,…) and the other works on the even-numbered days (2,4,6,)(2,4,6,…). The skill levels of Alice and Bob increase by A,BA,B respectively on the days they work.

Determine if it is possible that the skill levels of Alice and Bob become exactly P,QP,Q respectively on some day.

### Alternating Work Days solution codechef Input Format

• The first line contains an integer TT, denoting the number of test cases. The TT test cases then follow:
• The first and only line of each test case contains four space-separated integers A,B,P,QA,B,P,Q.

### Alternating Work Days solution codechef Output Format

For each test case, print YES if it is possible that the skill levels of Alice and Bob become exactly P,QP,Q on someday, 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).

### Alternating Work Days solution codechef Constraints

• 1T1031≤T≤103
• 1A,B,P,Q1091≤A,B,P,Q≤109

### Alternating Work Days solution codechef Subtasks

• Subtask 1 (100 points): Original constraints

### Sample Input 1

4
1 2 1 2
1 2 3 2
4 3 4 6
3 5 9 25


### Sample Output 1

YES
NO
YES
NO


### Alternating Work Days solution codechef Explanation

Test Case 11: Alice works on the first day and gains skill level 11. Bob works on the second day and gains skill level 22.

Test Case 22: There is no possible way that the skill levels of Alice and Bob become 33 and 22 respectively.

Test Case 33: Bob works on the first and third day and Alice works on the second day. Hence after the third day, the skill levels of Alice and Bob become 14=41⋅4=4 and 23=62⋅3=6 respectively.

Updating Soon… Minimise Difference solution codechef