codeforces 734B.Anton and Digits

Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6.

Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these integers as large as possible. Help him solve this task!

Each digit can be used no more than once, i.e. the composed integers should contain no more than k2 digits 2, k3 digits 3 and so on. Of course, unused digits are not counted in the sum.

Input

The only line of the input contains four integers k2, k3, k5 and k6 — the number of digits 2, 3, 5 and 6 respectively (0 ≤ k2, k3, k5, k6 ≤ 5·106).

Output

Print one integer — maximum possible sum of Anton's favorite integers that can be composed using digits from the box.

Examples
Input
5 1 3 4
Output
800
Input
1 1 1 1
Output
256

这个题的题意就是说Anton有k2个数字2,k3个数字3,k5个数字5,k6个数字6,然后用这些数字组合成256和32,要求组合起来的数字和最大,数字可以有剩余。首先这个题当然是优先组成256了,然后看组合成256之后是否有足够的数字2和3能接着组成32就行了,代码如下:

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int k1=2,k2=3,k3=5,k4=6;
	int a,b,c,d;
	int t=0,sum=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	t=min(a,min(c,d));
	if(t==a)  sum=256*a;
	if(t==c) 
	{
    if(b>(a-c))  sum=256*c+(a-c)*32;
	else if(b<=(a-c))  sum=256*c+b*32;
	}
	if(t==d)
	{
		if(b>(a-d))  sum=256*d+(a-d)*32;
		else if(b<=(a-d))  sum=256*d+b*32;
	}
	printf("%d\n",sum);
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值