CoderForces 734B

来源:互联网 发布:手机淘宝如何取消代付 编辑:程序博客网 时间:2024/05/16 11:35
B -B
Time Limit:1000MS    Memory Limit:262144KB    64bit IO Format:%I64d & %I64u
SubmitStatusPracticeCodeForces 734B

Description

Recently Anton found a box with digits in his room. There arek2 digits 2, k3 digits3, k5 digits5 and k6 digits6.

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 thank2 digits 2, k3 digits3 and so on. Of course, unused digits are not counted in the sum.

Input

The only line of the input contains four integersk2, k3, k5 andk6 — the number of digits2, 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

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

Hint

In the first sample, there are five digits 2, one digit 3, three digits 5 and four digits 6. Anton can compose three integers256 and one integer 32 to achieve the value256 + 256 + 256 + 32 = 800. Note, that there is one unused integer2 and one unused integer 6. They are not counted in the answer.

In the second sample, the optimal answer is to create on integer256, thus the answer is 256.


题解:水题,大意就是给你2 3 5 6的个数,让你求它们能够组成256 32的最大和,一看就知道先组256,然后再组32,其中特判一下注意数字个数别用超了。看代码。

#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;int main(){    int a,b,c,d,e,f;    long long s=0;    scanf("%d%d%d%d",&a,&b,&c,&d);    e=a>c?c:a;    e=e>d?d:e;    /*求2 5 6个数最少的*/     s+=e*256;     f=(a-e)>b?b:(a-e);     s+=f*32;     printf("%lld\n",s);}


0 0
原创粉丝点击