From c65a66b0c375af2dbd91124461fda49f6a44c81a Mon Sep 17 00:00:00 2001 From: AYUSH GUPTA <98117063+ayush-1123@users.noreply.github.com> Date: Sat, 22 Oct 2022 00:54:56 +0530 Subject: [PATCH] Create EqualizeAB Problem Statement: You are given two numbers AA and BB along with an integer XX. In one operation you can do one of the following: Set A = A + X and B = B - X Set A = A - X and B = B + X Determine if you can make A and B equal after applying the operation any number of times (possibly zero). --- EqualizeAB | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 EqualizeAB diff --git a/EqualizeAB b/EqualizeAB new file mode 100644 index 0000000..26ee178 --- /dev/null +++ b/EqualizeAB @@ -0,0 +1,34 @@ +// SOLUTION FOR PROBLEM Equalize AB, PROBLEM CODE - EQUALIZEAB, CODECHEF + +#include +using namespace std; +int main() +{ + int t; + cin >> t; + + while (t--) + { + int a, b, x; + cin >> a >> b >> x; + + if (a == b) + { + cout << "YES" << endl; + } + else + { + int n = abs(a - b); + + if ((n != x) && ((n % (x*2)) == 0)) + { + cout << "YES" << endl; + } + else + { + cout << "NO" << endl; + } + } + } + return 0; +}