Codeforces Round #379 (Div. 2) B. Anton and Digits 水题

B. Anton and Digits

题目连接:

http://codeforces.com/contest/734/problem/B

Description

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.

Sample Input

5 1 3 4

Sample Output

800

Hint

题意

给你2,3,5,6这四个数字的数量

让你组成256和32,使得和最大。

题解:

暴力枚举一种数的数量,然后算另外一个数的数量,然后输出答案就好了。

代码

#include<bits/stdc++.h>
using namespace std; int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
long long ans = 0;
for(int i=0;i<=d;i++){
long long num = min(a,min(c,d));
long long num2 = min(a-num,1ll*b);
ans=max(ans,num*256LL+32LL*num2);
}
cout<<ans<<endl;
}
上一篇:卸载金山猎豹免费WIfi后,上不了网的解决办法


下一篇:Pycharm用Ctrl+鼠标滚轮调节代码字体大小