-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lucky.java
25 lines (21 loc) · 835 Bytes
/
Lucky.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package Divisions.Div4.Round790;
//code by senurah
public class Lucky {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine();
if (n >= 1 && n <= 1000) {
for (int i = 0; i < n; i++) {
String ticket = scanner.nextLine();
int sumFirstHalf = (ticket.charAt(0) - '0') + (ticket.charAt(1) - '0') + (ticket.charAt(2) - '0');
int sumSecondHalf = (ticket.charAt(3) - '0') + (ticket.charAt(4) - '0') + (ticket.charAt(5) - '0');
if (sumFirstHalf == sumSecondHalf) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
}