【81.37%】【codeforces 734B】Anton and Digits
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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
Note
In the first sample, there are five digits 2, one digit 3, three digits 5 and four digits 6. Anton can compose three integers 256 and one integer 32 to achieve the value 256 + 256 + 256 + 32 = 800. Note, that there is one unused integer 2 and one unused integer 6. They are not counted in the answer.
In the second sample, the optimal answer is to create on integer 256, thus the answer is 256.
【题目链接】:http://codeforces.com/contest/734/problem/B
【题解】
贪心。
先选2,5,6这3个数字;
个数为min(k2,k5,k6);
然后再选3,2这两个数字;
个数同样为min(k3,k2);
然后加起来;
不知道会不会超long long;反正开就是了;
【完整代码】
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL k2,k3,k5,k6;
int main()
{
cin >> k2 >> k3 >>k5 >>k6;
LL ans = 0;
LL temp = min(k2,min(k5,k6));
k2-=temp,k5-=temp,k6-=temp;
ans += temp * 256;
temp = min(k3,k2);
ans += temp * 32;
cout << ans << endl;
return 0;
}
【81.37%】【codeforces 734B】Anton and Digits的更多相关文章
- 【 BowWow and the Timetable CodeForces - 1204A 】【思维】
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...
- 【81.82%】【codeforces 740B】Alyona and flowers
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【35.37%】【codeforces 556C】Case of Matryoshkas
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【21.37%】【codeforces 579D】"Or" Game
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【搜索】【并查集】Codeforces 691D Swaps in Permutation
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...
- 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【链表】【模拟】Codeforces 706E Working routine
题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别 ...
- 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions
题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...
随机推荐
- JVM route
http://www.linuxidc.com/Linux/2013-06/86446.htm
- dinic算法学习(以poj1273为例)
Dinic 算法模板 Dinic算法是一种比較easy实现的.相对照较快的最大流算法. 求最大流的本质,就是不停的寻找增广路径.直到找不到增广路径为止. 对于这个一般性的过程,Dinic算法的优化例 ...
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
在写自己定义的view时,有时会报下面错误: Caused by: java.lang.NoSuchMethodException: <init> [class android.co ...
- linux进入root模式
sudo su 然后输入密码 然后就会进入root模式,,,前面的提示符变成#
- 宝塔 ftp 不能连接 列出时出错
摘抄自 https://www.bt.cn/bbs/forum.php?mod=viewthread&tid=1903&page=1&extra=#pid6515 1.注意内网 ...
- 【Codeforces Round #440 (Div. 2) A】 Search for Pretty Integers
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 先枚举一个数字的情况. 再枚举两个数的情况就好. [代码] #include <bits/stdc++.h> #defi ...
- 【例题5-4 UVA - 156】Ananagrams
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每个字符串如果每个字符按照升序排一下.假设他们能够互相变化. 则肯定是一样的. 根据这个东西,用一个map来判重就好. [错的次数] ...
- CYPRESS USB芯片win10驱动
The ZIP file attached with this knowledge base article contains the CyUSB3.inf and CyUSB3.sys files ...
- hdu 5375 Gray code dp
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; cons ...
- swift开发网络篇 - post 请求
/** 所有网络请求,统一使用异步请求! 在今后的开发中,如果使用简单的get/head请求,可以用NSURLConnction异步方法 GET查/POST增/PUT改/DELETE删/HEAD GE ...