From 37b7e815612dec5655d2ee2363835e2075701ae6 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 29 Jun 2022 21:03:53 +0200 Subject: Solved the first 6 problems of codechef Starters --- codechef/chefAndHisApps/main.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 codechef/chefAndHisApps/main.cpp (limited to 'codechef/chefAndHisApps/main.cpp') diff --git a/codechef/chefAndHisApps/main.cpp b/codechef/chefAndHisApps/main.cpp new file mode 100644 index 0000000..8d38e22 --- /dev/null +++ b/codechef/chefAndHisApps/main.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int s, x, y, z; + cin >> s >> x >> y >> z; + int xy = x + y; + int free = s - xy; + int count = 0; + int mx = max(x, y); + // 3 <= 7 + if (z <= free) { + cout << 0 << endl; + } else { + while (z > free) { + z -= max(x, y); + if (x > y) { + x = 0; + } else { + y = 0; + } + count++; + } + cout << count << endl; + } + } +} -- cgit v1.2.3