#P7281. [COCI 2020/2021 #4] Vepar

[COCI 2020/2021 #4] Vepar

Description

Given two sets of positive integers {a,a+1,,b}\{a,a+1,\cdots,b\} and {c,c+1,,d}\{c,c+1,\cdots,d\}, determine whether c(c+1)dc \cdot (c+1)\cdots d is divisible by a(a+1)ba \cdot (a+1)\cdots b.

Input Format

The first line contains an integer tt, which indicates the number of test cases.

In the next tt lines, four integers ai,bi,ci,dia_i,b_i,c_i,d_i are given.

Output Format

Output tt lines in total. For the ii-th line, if ci(ci+1)dic_i \cdot (c_i+1)\cdots d_i is divisible by ai(ai+1)bia_i \cdot (a_i+1)\cdots b_i, output DA; otherwise, output NE.

2
9 10 3 6
2 5 7 9
DA
NE
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
DA
NE
DA
DA
DA
DA

Hint

Explanation for Sample 1

According to the statement, multiplying the numbers gives 9×10=909 \times 10=90 and 3×4×5×6=3603 \times 4 \times 5 \times 6=360. Since 9090 is divisible by 360360, output DA.

We get 2×3×4×5=1202 \times 3 \times 4 \times 5=120 and 7×8×9=5047 \times 8 \times 9=504. Since 120120 is not divisible by 504504, output NE.

Constraints and Specifications

This problem does not use bundled evaluation. You can get the corresponding score by passing the corresponding subtasks, but there are several constraints.

Constraint ID Score Constraints and Specifications
11 1010 ai,bi,ci,di50a_i,b_i,c_i,d_i \le 50
22 2020 ai,bi,ci,di1000a_i,b_i,c_i,d_i \le 1000
33 1010 ai=1a_i=1
44 3030 None

For 100%100\% of the testdata, 1t101 \le t \le 10, 1aibi1071 \le a_i \le b_i \le 10^7, 1cidi1071 \le c_i \le d_i \le 10^7.

Notes

The score of this problem follows the original COCI settings, with a full score of 7070.

Translated from COCI2020-2021 CONTEST #4 T2 Vepar.

Translated by ChatGPT 5