From 79bf7272de4a53ec80522bbb1d4c15c2cb336e4f Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Wed, 12 Jul 2023 00:39:14 +0600 Subject: [PATCH] initial commit --- 1311A Add Odd or Subtract Even/1311A.cpp | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 1311A Add Odd or Subtract Even/1311A.cpp diff --git a/1311A Add Odd or Subtract Even/1311A.cpp b/1311A Add Odd or Subtract Even/1311A.cpp new file mode 100644 index 0000000..ca5d27a --- /dev/null +++ b/1311A Add Odd or Subtract Even/1311A.cpp @@ -0,0 +1,55 @@ +#include +using namespace std; +using ll = long long; + + +void solve() +{ + int a,b; + cin>>a>>b; + int ct=0; + while(a!=b) + { + if(a==b) break; + else if(a>b) + { + int d=a-b; + if(d%2==0) + { + a=a-d; + ct++; + } + else + { + a=a-d-1; + ct++; + } + } + else + { + int d=b-a; + if(d%2!=0) + { + a=a+d; + ct++; + } + else + { + a=a+d-1; + ct++; + } + } + } + cout<> TC; + cin.ignore(); + while (TC--) solve(); +} \ No newline at end of file