Bitter Alchemy

https://abc095.contest.atcoder.jp/tasks/abc095_b

问题描述:

Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2…, Doughnut N. In order to make one Doughnut i (1iN), she needs to consume mi grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.

Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:

  • For each of the N kinds of doughnuts, make at least one doughnut of that kind.

At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.

问题分析:

问题大意就是共有N种甜甜圈,总量为X克,每种至少有一个,且要尽可能的多的数量的甜甜圈。

c++代码:

#include<iostream>
#include<cmath>
using namespace std;
#include<iomanip>
#include<algorithm>
const int N = 102;
int main(){
	ios::sync_with_stdio(false);
	int n,k;
	int a[N];
	cin>>n>>k;
	for(int i = 0;i < n;i++){
		cin>>a[i];
		k -= a[i];
	}
	sort(a,a+n);
	cout<<n+k/a[0]<<endl;
	return 0;
}

python代码:

N,X = list(map(int,input().split()))
M = [int(input()) for i in range(N)]
diff  = X - sum(M)
print(N+diff//min(M))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值