2021年浙大城市学院新生程序设计竞赛(同步赛) B Boboge and Tall Building

题目链接: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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值