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, \dots, b\} and \{c, c+1, \dots, d\} are given. Determine whether the product c \times (c+1) \times \dots \times d is divisible by the product a \times (a+1) \times \dots \times b.

Input Specification

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

Each of the following t lines contains four positive integers a_i, b_i, c_i, d_i (1 \le a_i \le b_i \le 10^7, 1 \le c_i \le d_i \le 10^7).

Output Specification

Output t lines in total. For the i^\text{th} test case, output DA if a \times (a+1) \times \dots \times b divides c \times (c+1) \times \dots \times d, and output NE otherwise.

Sample Input 1

2
9 10 3 6
2 5 7 9

Sample Output 1

DA
NE

Sample Explanation 1

We have 9 \cdot 10 = 90 and 3 \cdot 4 \cdot 5 \cdot 6 = 360. The answer is DA because 90 divides 360.

We calculate 2 \cdot 3 \cdot 4 \cdot 5 = 120, which doesn't divide 7 \cdot 8 \cdot 9 = 504. Thus the second answer is NE.

Sample Input 2

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

DA
NE
DA
DA
DA
DA

Comments

There are no comments at the moment.