#P16302. [蓝桥杯 2026 省 Java C 组] 幸运约会日

[蓝桥杯 2026 省 Java C 组] 幸运约会日

Problem 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 20262026 is 2+0+2+6=102 + 0 + 2 + 6 = 10.
  • The digit sum of 1212 is 1+2=31 + 2 = 3.
  • The digit sum of 2525 is 2+5=72 + 5 = 7.

Given a date, please help Xiaoming determine whether it is a lucky date day.

Input Format

The first line contains an integer TT, indicating the number of test cases.

The next TT lines each contain three integers YY, MM, and DD, 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.

3
2026 12 7
2020 4 13
1111 1 3
NO
YES
NO

Hint

Sample Explanation

  • The first date: December 7, 2026. The digit sum of 2026: 2+0+2+6=102 + 0 + 2 + 6 = 10. The digit sum of 12: 1+2=31 + 2 = 3. The digit sum of 7: 77. Since 10≠3≠710 \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=42 + 0 + 2 + 0 = 4. The digit sum of 4: 44. The digit sum of 13: 1+3=41 + 3 = 4. Since 4=4=44 = 4 = 4, it is a lucky date day.
  • The third date: January 3, 1111. The digit sum of 1111: 1+1+1+1=41 + 1 + 1 + 1 = 4. The digit sum of 1: 11. The digit sum of 3: 33. Since 4≠1≠34 \ne 1 \ne 3, it is not a lucky date day.

Constraints

For all test cases, 1≤T≤10001 \le T \le 1000, 1000≤Y≤99991000 \le Y \le 9999 (guaranteed to be a valid year), 1≤M≤121 \le M \le 12 (guaranteed to be a valid month), and 1≤D≤311 \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