Skip to content

Commit 95f53d2

Browse files
commit
1 parent 8a9357a commit 95f53d2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

potd/Arithmetic Number.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//{ Driver Code Starts
2+
// Initial Template for C++
3+
4+
#include <bits/stdc++.h>
5+
using namespace std;
6+
7+
// } Driver Code Ends
8+
// User function Template for C++
9+
10+
class Solution
11+
{
12+
public:
13+
int inSequence(int A, int B, int C)
14+
{
15+
if (C == 0 && A == B)
16+
{
17+
return 1;
18+
}
19+
double n = (double)(B - A) / C + 1;
20+
21+
return (n > 0 && n == int(n));
22+
// return (n > 0 && n==int(n)) ? 1 : 0;
23+
}
24+
};
25+
26+
//{ Driver Code Starts.
27+
28+
int main()
29+
{
30+
int t;
31+
cin >> t;
32+
while (t--)
33+
{
34+
int A, B, C;
35+
cin >> A >> B >> C;
36+
37+
Solution ob;
38+
cout << ob.inSequence(A, B, C) << endl;
39+
}
40+
return 0;
41+
}
42+
// } Driver Code Ends

0 commit comments

Comments
 (0)