From 5fd245205999b60e61e2e3e488d17f0c04cae4dd Mon Sep 17 00:00:00 2001 From: MD S M Sarowar Hossain <67090247+Sarowar-s@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:49:17 +0600 Subject: [PATCH 1/3] Create en.md This solution fixes the run rate calculation bug in the electronic scoreboard system by correctly computing: -Balls played -Runs needed -Proper decimal formatting using fixed and setprecision(2) --- dimik-run-rate-1/en.md | 110 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 dimik-run-rate-1/en.md diff --git a/dimik-run-rate-1/en.md b/dimik-run-rate-1/en.md new file mode 100644 index 00000000..ef985c74 --- /dev/null +++ b/dimik-run-rate-1/en.md @@ -0,0 +1,110 @@ +# Run Rate 1 + +## Problem Summary + +In a 50-over ODI cricket match: + +- Total balls = 50 × 6 = 300 +- We are given: + - r1 → Opponent’s total runs + - r2 → Current runs of batting team + - B → Remaining balls + +We need to calculate: + +1. Current Run Rate (CRR) +2. Required Run Rate (RRR) + +Each value must be printed with exactly two digits after the decimal point. + +--- + +## Important Cricket Rules + +- 1 over = 6 balls +- To win, the batting team must score at least 1 run more than the opponent. +- Balls played = 300 - B + +--- + +## Formula Explanation + +### 1. Current Run Rate (CRR) + +Current Run Rate is calculated based on runs scored and balls already played. + +CRR = (r2 × 6) / balls_played + +Where: + +balls_played = 300 - B + +We multiply by 6 because run rate is calculated per over (6 balls). + +--- + +### 2. Required Run Rate (RRR) + +First, calculate runs needed to win: + +runs_needed = (r1 + 1) - r2 + +If runs_needed becomes negative, we set it to 0 because the team has already won. + +Then, + +RRR = (runs_needed × 6) / B + +This calculates how many runs per over are required in the remaining balls. + +--- + +## Edge Cases Considered + +- If balls_played = 0, CRR is set to 0.00. +- If B = 0, RRR is set to 0.00. +- If the team already won, required run rate becomes 0.00. + +--- + +## C++ Implementation + +```cpp +#include +#include // for setprecision and fixed value + +using namespace std; + +int main() +{ + int n; + cin >> n; //test case + + while (n--) + { + long long r1, r2, B; + cin >> r1 >> r2 >> B; //three required variables + + long long ball_played = 300 - B; // 50 overs = 50 * 6 = 300 balls + + double current_run_rate = 0.0; //if no ball played, crr = 0 + if (ball_played > 0){ + current_run_rate = (r2 * 6.0) / ball_played; //if balls played, calculate the RR + } + double run_needed = (r1 + 1) - r2; + if (run_needed < 0) { + run_needed = 0; //if the player get 2, 3, 4 or 6 runs when 1 run is required, + // the run_needed calculation return (-)negative value, so we need to + // set the value to 0, cause already won the match. + } + double required_run_rate = 0.0; + if (B > 0) { + required_run_rate = (run_needed * 6.0) / B; + } + cout << fixed << setprecision(2) + << current_run_rate << " " + << required_run_rate << endl; + } + + return 0; +} From c6f5a7c96e6d61b9c9c943292a27cbd8b0018ced Mon Sep 17 00:00:00 2001 From: MD S M Sarowar Hossain <67090247+Sarowar-s@users.noreply.github.com> Date: Wed, 11 Feb 2026 23:09:46 +0600 Subject: [PATCH 2/3] Create bn.md This solution fixes the run rate calculation bug in the electronic scoreboard system by correctly computing: -Balls played -Runs needed -Proper decimal formatting using fixed and setprecision(2) //Bangla version --- dimik-run-rate-1/bn.md | 114 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 dimik-run-rate-1/bn.md diff --git a/dimik-run-rate-1/bn.md b/dimik-run-rate-1/bn.md new file mode 100644 index 00000000..0c9687ba --- /dev/null +++ b/dimik-run-rate-1/bn.md @@ -0,0 +1,114 @@ + +# রান রেট ১ + +## সমস্যার সারসংক্ষেপ + +৫০ ওভারের একটি ওয়ানডে ক্রিকেট ম্যাচে: + +- মোট বল = ৫০ × ৬ = ৩০০ বল +- ইনপুট হিসেবে নিতে হয়: + - r1 → প্রতিপক্ষের মোট রান + - r2 → বর্তমান ব্যাটিং দলের রান + - B → বাকি বলের সংখ্যা + +আমাদের বের করতে হবে: + +1. বর্তমান রান রেট (Current Run Rate) +2. জয়ের জন্য প্রয়োজনীয় রান রেট (Required Run Rate) + +প্রতিটি মান দশমিকের পরে ঠিক দুই ঘর পর্যন্ত প্রিন্ট করতে হবে। + +--- + +## গুরুত্বপূর্ণ নিয়ম + +- ৬ বল = ১ ওভার +- জিততে হলে প্রতিপক্ষের চেয়ে অন্তত ১ রান বেশি করতে হবে +- খেলা হয়েছে এমন বল = 300 - B + +--- + +## ব্যাখ্যা + +### ১. বর্তমান রান রেট + +বর্তমান রান রেট নির্ণয় করা হয় ইতিমধ্যে করা রান এবং খেলা হওয়া বলের উপর ভিত্তি করে। + +বর্তমান রান রেট = (r2 × 6) / খেলা হওয়া বল + +যেখানে, + +খেলা হওয়া বল = 300 - B + +৬ দিয়ে গুণ করা হয় কারণ রান রেট ওভারপ্রতি (৬ বল) হিসাব করা হয়। + +--- + +### ২. প্রয়োজনীয় রান রেট + +প্রথমে জয়ের জন্য প্রয়োজনীয় রান বের করি: + +প্রয়োজনীয় রান = (r1 + 1) - r2 + +যদি মান ঋণাত্মক হয়, তাহলে ০ ধরা হয়, কারণ দল ইতিমধ্যে জিতে গেছে। + +তারপর, + +প্রয়োজনীয় রান রেট = (প্রয়োজনীয় রান × 6) / B + +এটি বাকি বলগুলিতে ওভারপ্রতি কত রান করতে হবে তা নির্দেশ করে। + +--- + +## সংক্ষেপে + +- যদি খেলা হওয়া বল ০ হয়, তাহলে বর্তমান রান রেট 0.00। +- যদি বাকি বল ০ হয়, তাহলে প্রয়োজনীয় রান রেট 0.00। +- যদি দল ইতিমধ্যে জিতে যায়, তাহলে প্রয়োজনীয় রান রেট 0.00। + +--- + +## C++ সমাধান + +```cpp +//------ Contributor ~ --------// +//------ MD. S. M. Sarowar Hossain --------// +//------ Varendra University --------// + +#include +#include //setprecision আর fixed value এর জন্য দরকারি + +using namespace std; + +int main() +{ + int n; + cin >> n; + + while (n--) + { + long long r1, r2, B; + cin >> r1 >> r2 >> B; + + long long ball_played = 300 - B; //৫০ ওভার = ৫০*৬ = ৩০০ বল + + double current_run_rate = 0.0; + if (ball_played > 0){ // যদি একটাও বল না খেলে, তাহলে রান রেট ০.০। + current_run_rate = (r2 * 6.0) / ball_played; + } + double run_needed = (r1 + 1) - r2; + if (run_needed < 0) { //যদি ১ রানের প্রয়োজন হয়, এমন সময় ব্যাটস্‌ম্যান ৪, ৬ রান সংগ্রহ করে, + // তাহলে খণাত্বক সংখ্যা দেখাবে, তাই if দিয়ে এমন ঘটনা এড়াতে হবে + run_needed = 0; + } + double required_run_rate = 0.0; + if (B > 0){ + required_run_rate = (run_needed * 6.0) / B; + } + cout << fixed << setprecision(2) + << current_run_rate << " " + << required_run_rate << endl; + } + + return 0; +} From 4d9411ee7ad77de817342dbb0b92acc50b8a71cf Mon Sep 17 00:00:00 2001 From: MD S M Sarowar Hossain <67090247+Sarowar-s@users.noreply.github.com> Date: Wed, 11 Feb 2026 23:12:28 +0600 Subject: [PATCH 3/3] Update en.md --- dimik-run-rate-1/en.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dimik-run-rate-1/en.md b/dimik-run-rate-1/en.md index ef985c74..efaa57dd 100644 --- a/dimik-run-rate-1/en.md +++ b/dimik-run-rate-1/en.md @@ -70,6 +70,10 @@ This calculates how many runs per over are required in the remaining balls. ## C++ Implementation ```cpp +//------ Contributor ~ --------// +//------ MD. S. M. Sarowar Hossain --------// +//------ Varendra University --------// + #include #include // for setprecision and fixed value