Masala #MNDV0FDD6D
Beautiful numbers
A four-digit number \(ABCD \) is beautiful if \(AB^2 + CD^2 \)when divided by \(7\) gives a remainder of \(1\).
For example, the number \(2843 \) is beautiful because
\(28^2 + 43^2 = 2633 = 376 * 7 + 1.\)
You are given \(t\) four-digit numbers, print \(YES \)for each number if the number is beautiful and \(NO\), otherwise
The first line contains a natural number \(t (1 ≤ t ≤ 10^4)\). Then there are t four-digit numbers.
If the number is nice, print \(YES\), otherwise \(NO\).
# | input.txt | output.txt |
---|---|---|
1 |
3 2843 8243 0100 |
YES NO YES |