题目链接:B-Boboge and Tall Building_2021年浙大城市学院新生程序设计竞赛(同步赛) (nowcoder.com)
题目描述
Boboge lives on the n-th floor of a building with a total height of k. This building has m floors and each floor is of equal height, the height of first floor is 0.
You have to calculate the height of the floor Boboge lives in.
Example of n=3, m=4, k=10:
输入描述:
The first line contains an integer t(1≤t≤100) --- the number of test cases. Each test case is described by three integers n,m,k(1≤n,m,k≤100,n≤m) --- the floor Boboge lives in, number of total floors and total height of the building.
输出描述:
For each test case, output the height of the floor Boboge lives in. Your answer will be accepted if absolute or relative error does not exceed 10−6. Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if ∣a−b∣/ max(1,∣b∣)≤10−6。
示例1
输入
3 3 4 10 1 4 10 2 3 10
输出
5.0000000000 0.0000000000 3.3333333333
题意:一个高为k的楼房有m层,问n层地板到0层0板的高度
思路:高度为: k / m * (n - 1)
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
double n, m, k;
while(t--){
cin >> n >> m >> k;
printf("%.10f\n", k / m * (n - 1));
}
return 0;
}