zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    第八周上机作业
    第七周课后作业
    第七周上机作业
    第六周课后作业
    第六周上机
    第九周JAVA
    第八周JAVA
    第8次JAVA作业
    第七周JAVA
    第7周JAVA
  • 原文地址:https://www.cnblogs.com/qscqesze/p/6069133.html
Copyright © 2011-2022 走看看