-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmetic Number.java
More file actions
45 lines (38 loc) · 1.05 KB
/
Arithmetic Number.java
File metadata and controls
45 lines (38 loc) · 1.05 KB
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
38
39
40
41
42
43
44
45
//{ Driver Code Starts
//Initial Template for Java
import java.io.*;
import java.util.*;
class GFG{
public static void main(String args[])throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(System.out);
int t = Integer.parseInt(in.readLine());
while(t-- > 0){
String arr[] = in.readLine().trim().split("\\s+");
int A = Integer.parseInt(arr[0]);
int B = Integer.parseInt(arr[1]);
int C = Integer.parseInt(arr[2]);
Solution ob = new Solution();
out.println(ob.inSequence(A, B, C));
}
out.close();
}
}
// } Driver Code Ends
//User function Template for Java
class Solution{
static int inSequence(int A, int B, int C){
// code here
if(C==0)
{
if(A==B)
return 1;
else
return 0;
}
if((B-A)%C==0 && (B-A)/C>=0)
return 1;
return 0;
}
}