COCI '20 Contest 4 #2 Vepar

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.5s
Memory limit: 512M

Problem type

Two intervals of positive integers {a,a+1,,b} and {c,c+1,,d} are given. Determine whether the product c×(c+1)××d is divisible by the product a×(a+1)××b.

Input Specification

The first line contains a single integer t (1t10), the number of independent test cases.

Each of the following t lines contains four positive integers ai, bi, ci, di (1aibi107,1cidi107).

Output Specification

Output t lines in total. For the ith test case, output DA if a×(a+1)××b divides c×(c+1)××d, and output NE otherwise.

Sample Input 1

Copy
2
9 10 3 6
2 5 7 9

Sample Output 1

Copy
DA
NE

Sample Explanation 1

We have 910=90 and 3456=360. The answer is DA because 90 divides 360.

We calculate 2345=120, which doesn't divide 789=504. Thus the second answer is NE.

Sample Input 2

Copy
6
1 2 3 4
1 4 2 3
2 3 1 4
1 3 2 4
19 22 55 57
55 57 19 22

Sample Output 2

Copy
DA
NE
DA
DA
DA
DA

Comments

There are no comments at the moment.