CodeForces 734B Anton and Digits

贪心。先取$256$,再取$32$。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
void File()
{
    freopen("D:\\in.txt","r",stdin);
    freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c = getchar();
    x = 0;
    while(!isdigit(c)) c = getchar();
    while(isdigit(c))
    {
        x = x * 10 + c - ‘0‘;
        c = getchar();
    }
}

char s[100010];
long long k2,k3,k5,k6;

int main()
{
    cin>>k2>>k3>>k5>>k6;

    long long mn=min(k2,min(k5,k6));

    long long ans=mn*256;

    k2-=mn;
    k5-=mn;
    k6-=mn;

    ans+=min(k2,k3)*32;

    cout<<ans<<endl;

    return 0;
}
时间: 2024-12-25 05:50:01

CodeForces 734B Anton and Digits的相关文章

codeforces 509C Sums of Digits

codeforces 509C Sums of Digits 题意: 给出n个数字各位的加和bi,求一个严格递增的数列.要求最后一个数字最小. 如: 3 2 1 -> 3 11 100 限制: 1 <= n <= 300; 1 <= bi <=300 思路: 贪心,要求最后一个数字最小,只要保证一路过来的数字都尽量小就行. 令d=b[i]-b[i-1], 如果d>0,则从最低位填起,尽量把低位填到9 如果d<=0,则先从低位开始进位,使得d>0,然后就可以转

codeforces 785C Anton and Fairy Tale

题目链接:http://codeforces.com/problemset/problem/785/C 题意:仓库容量是n,一开始是满的,然后每天晚上可以往仓库里装m粮食,最多装到n.然后每天白天有鸟来吃粮食,一只鸟吃1单位.第i天有i只鸟.问你多少天鸟可以把粮食吃完. 分析:一开始读错题,导致wa了两发.如果n<=m的话,只有n只鸟的时候一天把他吃完,输出n.如果m<n的话,前m是肯定吃不完的,m天之后,从1开始计数,就是好比每天白天吃i+m,晚上装m,一天好比加了i.所以可以二分天数,但是

Codeforces 734C Anton and Making Potions(枚举+二分)

题目链接:http://codeforces.com/problemset/problem/734/C 题目大意:要制作n个药,初始制作一个药的时间为x,魔力值为s,有两类咒语,第一类周瑜有m种,每种咒语使制作一个药的时间变成a[i],花费b[i]的魔力,第二类咒语有k种,每种咒语瞬间产生c[i]个药,花费d[i]的魔力,c[i]和d[i]都是不递减的,求最短时间内产生n个药的时间.解题思路:因为c[i]和d[i]都是不降的,所以可以枚举a[i],然后二分查找花费小于t-b[i]的第二类咒语.注

CodeForces 593B Anton and Lines

计算出每条线段在x1处的y坐标和x2处的y坐标. 就下来只要根据每条线段左右两处的y坐标就可以判断是否有交点. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; long long INF=9999999999999999; long long x1,x2; int n; struct X { long long k,b; l

CodeForces 734F Anton and School

位运算. 两个数的和:$A+B=(AandB)+(AorB)$,那么$b[i]+c[i]=n*a[i]+suma$.可以解出一组解,然后再按位统计贡献验证一下. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<v

CodeForces 734E Anton and Tree

$dfs$缩点,树形$dp$. 首先将连通块缩点,缩点后形成一个黑白节点相间的树.接下来的任务就是寻找一个$root$,使这棵树以$root$为根,树的高度是最小的(也就是一层一层染色).树形$dp$可以解决这个问题,第一次$dfs$处理子树,第二次$dfs$枚举$root$计算答案. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring>

codeforces 584E Anton and Ira [想法题]

题意简述: 给定一个$1$到$n(n<=2000)$的初始排列以及最终排列 我们每次可以选取位置为$i$和$j$的 并交换它们的位置 花费为$ |i-j| $ 求从初始状态变换到末状态所需最小花费 ----------------------------------------------------------------------------------------------------------- 比赛时这题留了$40min$ 然而自己贪心策略还是有漏洞 结束后看了首页的官方题解 感

CodeForces 785E Anton and Permutation

分块,暴力. 将序列分成$sqrt(n)$块,每块$sqrt(n)$个元素,每块内排序. 每次操作要计算这个区间中比$a[p1]$大的有几个,小的有几个,比$a[p2]$大的有几个,小的有几个,端点的块内暴力找,中间的块内二分找. 交换完数字之后,可以直接重新$sort$排个序. 总体时间复杂度$O(m*log(sqrt(n))*sqrt(n))$. #include <cstdio> #include <cmath> #include <cstring> #inclu

CodeForces 785A Anton and Polyhedrons

简单判断. 分别判断每个单词是几面体,加起来就是答案. #include <cstdio> #include <cmath> #include <cstring> #include <map> #include <algorithm> using namespace std; int n; char s[1000]; int sum; int main() { scanf("%d",&n); for(int i=1;i