From dc0f2c7d7b6c4e6aa5956de3e783c85fb71a8eaf Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Wed, 1 Jun 2022 19:11:49 +0200 Subject: Solved 6 problems in codechef starters 41(Div.4) --- contests/Codechef_Starters_41/D/main.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 contests/Codechef_Starters_41/D/main.cpp (limited to 'contests/Codechef_Starters_41/D/main.cpp') diff --git a/contests/Codechef_Starters_41/D/main.cpp b/contests/Codechef_Starters_41/D/main.cpp new file mode 100644 index 0000000..a0365c2 --- /dev/null +++ b/contests/Codechef_Starters_41/D/main.cpp @@ -0,0 +1,26 @@ +#include +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int x, y; + cin >> x >> y; + if(x > y) { + if((x - y) % 2 == 0) { + cout << (x - y) / 2 << endl; + } else { + cout << (x - y) / 2 + 2 << endl; + } + } else if (y > x) { + cout << y - x << endl; + } else { + cout << 0 << endl; + } + } +} -- cgit v1.2.3