We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a9357a commit 95f53d2Copy full SHA for 95f53d2
potd/Arithmetic Number.cpp
@@ -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
0 commit comments