-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDigitGame.java
More file actions
33 lines (33 loc) · 863 Bytes
/
DigitGame.java
File metadata and controls
33 lines (33 loc) · 863 Bytes
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
26
27
28
29
30
31
32
33
import java.util.*;
public class DigitGame {
private static boolean game(int[] nums){
int sSum = 0;
int dSum = 0;
for (int i = 0; i < nums.length; i++) {
int num = (int)Math.floor(Math.log10(nums[i]) + 1);
if (num == 1) {
sSum += nums[i];
}
if (num == 2) {
dSum += nums[i];
}
}
if (sSum == dSum) {
return false;
}
else{
return true;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
boolean ans = game(arr);
System.out.println(ans);
sc.close();
}
}