A.Cut Ribbon

A.Cut Ribbon

切断带

time limit per test: 1 second
每次测试的时间限制:1秒

memory limit per test:256 megabytes
每次测试的内存限制:256兆字节

input: standard input
输入:标准输入

output: standard output
产出:标准产出

Polycarpus has a ribbon, its length is n.He wants to cut the ribbon in a way that fulils the following two conditions:
Polycarpus has a ribbon, its length is n.He wants to cut the ribbon in a way that fulils the following two conditions:

. After the cutting each ribbon piece should have length a,b or c.
。剪裁后,每条丝带的长度应为a、b或c。

. After the cutting the number of ribbon pieces should be maximum.
。剪裁后,丝带的数量应该是最大的。

Help Polycarpus and find the number of ribbon pieces after the required cutting.
帮助Polycarpus找到剪裁后丝带的数量。

lnput
输入

The first line contains four space-separated integers n,a, b and c (1≤n,a,b,c≤4000)—the length of the original ribon and the
第一行包含四个空格分隔的整数n,a,b和c(1≤n,a,b,c≤4000)–原始Ribon的长度和

acceptable lengths of the ribbon pieces after the cutting, correspondingly.The numbers a, b and c can coincide.
剪裁后丝带的可接受长度相应。数a、b和c可重合。

output
输出量

Print a single number—the maximum possible number of rbon pieces.t is guaranteed that at least one correctribon cutting exists.
打印一个数字-最大可能数量的碳片。t是保证至少有一个正确的三边切割存在。
贪心

int main()
{
	int n, a, b, c;
	int i, j, t, max = 0;
	cin >> n >> a >> b >> c;

	for (i = 0; i <= n; i+=a)
	{
		for (j = 0; i + j  <= n; j+=b)
		{
			if ((n - i - j ) % c == 0 && (n - i  - j ) / c + i/a + j/b > max)
			{
				max = (n - i  - j ) / c + i/a + j/b;
			}
		}
	}
	cout<< max << endl;

	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值