【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 < ...
随机推荐
- STL之vector容器的实现框架
说明:本文仅供学习交流,转载请标明出处,欢迎转载. 实现vector容器的思路等同于实现一个动态数组,以下我们參照源代码的相关资料,给出一个vector容器的大致框架,仅仅有声明,没给出详细的实现. ...
- [Web Security] Create a hash salt password which can stored in DB
We cannot directly store user password in the database. What need to do is creating a hashed & s ...
- C++开源码项目汇总
Google的C++开源码项目 v8 - V8 JavaScript Engine V8 是 Google 的开源 JavaScript 引擎. V8 採用 C++ 编写,可在谷歌浏览器(来自 G ...
- 辛星彻底帮您解决CSS中的浮动问题
浮动,是CSS布局中必须经过的一道坎,假设不熟悉浮动.那么CSS的布局就如同空中楼阁,而谈到浮动,很多其它的是和div相结合,div是一个块级元素.这个我前面的博文有介绍,假设大家喜欢我的风格,能够搜 ...
- 学习redis--简介(一)
1.什么是redis? Redis是使用c语言开发的一个高性能键值数据库.Redis通过键值类型来存储数据.它通过提供多种键值数据类型来适应不同场景的存储需求. 2.redis支持哪些数据类型 Key ...
- UVA 11889 - Benefit 可直接枚举
看题传送门 题目大意: 输入两个整数A和C,求最小的整数B,使得lcm(A,B)=C.如果无解,输出NO SOLUTION 思路: A*B=C*gcd(A,B) 所以 B / gcd(A,B) = C ...
- 快速理解Java中的五种单例模式(转)
解法一:只适合单线程环境(不好) package test; /** * @author xiaoping * */ public class Singleton { private static S ...
- linux系统进程的查看与控制
原文:linux系统进程的查看与控制 一.什么是进程? 进程就是系统未完成并且正在进行的工作. 二.查看系统进程 1.图形方式查看 gnome-system-monitor 2.进程查看命令 ps - ...
- 【5001】n皇后问题
Time Limit: 10 second Memory Limit: 2 MB 在n*n的棋盘上放置n个皇后(国际象棋中的皇后,n≤10)而彼此不受攻击(即在棋盘的任一行,任一列和任一对角线上不能放 ...
- LLRB——红黑树的现代实现
一.本文内容 以一种简明易懂的方式介绍红黑树背后的逻辑实现2-3-4树,以及红黑树的插入.删除操作,重点在2-3-4树与红黑树的对应关系上,并理清红黑树相关操作的来龙去脉.抛弃以往复杂的实现,而分析红 ...