As the cricket fever is on,you are given the task of calculating the run rate of a cricket match,but you are only provided with overs completed , current run rate and runs scored in next over.So you have to calculate the new run rate correctly upto two decimal places.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains three space-separated integers O R S
O denotes overs completed, R denotes current run rate and S denotes runs scored in next over.
Output
Print the new run rate correctly upto two decimal places
Constraints
1 ≤ T ≤ 1000
1 ≤ O ≤ 50
1 ≤ R ≤ 36
1 ≤ S ≤ 36
Example
Input:
1
16 6 8
Output:
6.12
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
We are given a problem: "As the cricket fever is on, you are given the task of calculating the run rate of a cricket match, but you are only provided with overs completed, current run rate and runs scored in next over. So you have to calculate the new run rate correctly up to two decimal places."
Input: first line integer T, then T lines each with three space-separated integers O R S. O denotes overs completed, R denotes current run rate, and S denotes runs scored in next over.
Output: Print the new run rate correctly up to two decimal places.
Constraints: T up to 1000, O from 1 to 50, R from 1 to 36, S from 1 to 36.
Example: Input: 1, 16 6 8 -> Output: 6.12
Interpretation: In cricket, run rate = total runs scored divided by total overs faced. Initially, we have overs completed = O, and current run rate = R. From the current run rate, we can infer the total runs scored so far. Because run rate = total runs / overs. So total runs so far = O * R. But careful: In cricket, overs are usually measured in number of overs (like 16 overs) but sometimes overs can be fractional? But here O is integer, but run rate is given as integer? Actually R is integer according to input. However run rate is often a decimal but here given as integer. But in constraints R is between 1 and 36, so likely integer. So initial total runs = O * R.
Then next over: they score S runs in that over. So total runs become O * R + S. Overs become O + 1 (since one more over is completed). Then new run rate = (O * R + S) / (O + 1). We need to print up to two decimal places.
Check example: O=16, R=6, S=8 => total runs = 16*6 = 96. After over: 96+8=104. Overs=17. New RR=104/17 ≈ 6.117647... Rounded to two decimal places: 6.12 (since 6.1176 rounds up? Actually 6.1176 to two decimals is 6.12? Let's compute: 104/17 = 6.1176470588. Round to two decimal places: look at third decimal digit is 7, so rounding up: 6.12. So matches.
Thus the solution is straightforward: For each test case, compute new_run_rate = (O * R + S) / (O + 1). Print with two decimal places.
Potential pitfalls: Input as integers but need floating division. Use double or float. Ensure correct rounding. In C++ can use printf("%.2f", value) which rounds half away from zero? Actually printf uses rounding half away from zero? Typically it's round half away from zero? In C++ the rounding for printf with %f uses round half away from zero? Actually, it's "round half away from zero" or "round half to even"? I think it's round half away from zero (i.e., 0.5 rounds up). But most implementations use round half away from zero? Actually, in C's printf, rounding is to the nearest representable, but when formatting, it uses the rounding mode of the floating-point environment, often round half away from zero? Actually, glibc's printf uses round-half-even? I'm not entirely sure. But typical online judges accept printf("%.2f") if you compute accurately. However, to be safe, we can add a small epsilon before rounding? But likely fine.
Also note that O and R up to 50 and 36, product up to 1800, plus S up to 36, so within integer range.
Thus solution: For each test case, read O, R, S. Compute numerator = O * R + S (integer). denominator = O + 1 (integer). Compute result = numerator / (denominator as double). Print using formatting to two decimal places.
But be careful: In some cricket contexts, overs are counted as balls? But here it's overs completed, which is integer number of overs. So the approach is correct.
I'll write solution accordingly.
Now produce final answer: Explanation and code.
We need to output for each test case the new run rate with two decimals.
We'll write in C++.
Implementation:
code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
int O, R, S;
cin >> O >> R >> S;
double new_rr = (O * R + S) / (double)(O + 1);
printf("%.2f\n", new_rr);
}
return 0;
}
That's it.
Now we also produce reasoning.
But also check if O could be zero? According to constraints, O >= 1, so denominator non-zero.
Thus final answer. ```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int O, R, S;
cin >> O >> R >> S;
// total runs after next over
int total_runs = O * R + S;
// total overs after next over
int total_overs = O + 1;
// new run rate
double new_rr = (double)total_runs / total_overs;
// output with exactly two decimal places
printf("%.2f\n", new_rr);
}
return 0;
}