-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatchsticks game.java
More file actions
37 lines (31 loc) · 876 Bytes
/
Matchsticks game.java
File metadata and controls
37 lines (31 loc) · 876 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
34
35
36
37
//{ Driver Code Starts
//Initial Template for Java
import java.io.*;
import java.util.*;
class GFG {
public static void main(String args[]) throws IOException {
BufferedReader read =
new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(read.readLine());
while (t-- > 0) {
Long N = Long.parseLong(read.readLine());
Solution ob = new Solution();
System.out.println(ob.matchGame(N));
}
}
}
// } Driver Code Ends
//User function Template for Java
class Solution {
static int matchGame(Long N) {
// code here
String s = new String(""+N);
int lastDigit = Integer.parseInt(""+s.charAt(s.length()-1));
if(lastDigit % 5 == 0)
{
return -1;
}
int res = lastDigit % 5;
return res;
}
};