问题 B: ISU

题目描述

We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.
We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.
At most how many people can sit on the seat?

Constraints
All input values are integers.
1≤X,Y,Z≤105
Y+2Z≤X

输入

Input is given from Standard Input in the following format:
X Y Z

输出

Print the answer.

样例输入

13 3 1

样例输出

3

提示

There is just enough room for three, as shown below:

一道水题, 题意就是说给一个长度为x 公分的板凳,然后上面坐人,每个人占据 y 公分 ,间隔为z 公分 .

可以解方程 ,设可以最多坐 C 人 ,那么 x = Cy+z(C+1) ;

C = x-z/y+z ;

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define d(x) for(int i = 1 ;i<=(x) ; i++)
#define Init_(x)	memset(x,0,sizeof(x))
#define pi acos(-1)
#define while_(x) while(scanf("%d",&x)!=EOF)
#define while_c(x) while(x--)
#define scanf_(x,y)  scanf("%d%d",&x,&y)
#define mst(a,b) memset((a),(b),sizeof(a))
using namespace std ;
typedef long long LL ;
const LL Mod = 1e9+7 ;

int main()
{
	
	int x, y ,z ;
	cin >> x >>y >>z ; // x 为长度 ,y每个人的宽度 ,z为间隔
	
	int m = x-z ;
	int n = y+z ;
	cout<<m/n<<endl;
	
	
	
	
	return 0 ;
}

猜你喜欢

转载自blog.csdn.net/qq_41661809/article/details/81488388