P16302 [Lanquiao Cup 2026 NOI Qualifier Java Group C] Lucky Date Day

Description

Xiaoming is a romantic programmer. He wants to confess his feelings to the girl he likes on a special date. He believes that if the digit sums of the three numbers year, month, and day of a date are all equal, then this is a "lucky date day". A digit sum means the sum of all digits of a number. For example: - The digit sum of $2026$ is $2 + 0 + 2 + 6 = 10$. - The digit sum of $12$ is $1 + 2 = 3$. - The digit sum of $25$ is $2 + 5 = 7$. Given a date, please help Xiaoming determine whether it is a lucky date day.

Input Format

The first line contains an integer $T$, indicating the number of test cases. The next $T$ lines each contain three integers $Y$, $M$, and $D$, representing the year, month, and day, respectively.

Output Format

For each test case, if it is a lucky date day, output YES; otherwise output NO.

Explanation/Hint

### Sample Explanation - The first date: December 7, 2026. The digit sum of 2026: $2 + 0 + 2 + 6 = 10$. The digit sum of 12: $1 + 2 = 3$. The digit sum of 7: $7$. Since $10 \ne 3 \ne 7$, it is not a lucky date day. - The second date: April 13, 2020. The digit sum of 2020: $2 + 0 + 2 + 0 = 4$. The digit sum of 4: $4$. The digit sum of 13: $1 + 3 = 4$. Since $4 = 4 = 4$, it is a lucky date day. - The third date: January 3, 1111. The digit sum of 1111: $1 + 1 + 1 + 1 = 4$. The digit sum of 1: $1$. The digit sum of 3: $3$. Since $4 \ne 1 \ne 3$, it is not a lucky date day. ### Constraints For all test cases, $1 \le T \le 1000$, $1000 \le Y \le 9999$ (guaranteed to be a valid year), $1 \le M \le 12$ (guaranteed to be a valid month), and $1 \le D \le 31$ (guaranteed to be a valid date). It is guaranteed that the given dates are all real and valid dates. Translated by ChatGPT 5