Codeforces Round #274 (Div. 2) 解题报告

app逆向分析案例-95分 先把justtrusmeplus打开设置好95分,开始抓包,得到结果为: https://www.95fenapp.com/api_goods/list/v3.0?is_all=1&keywords=%E7%A7%91%E6%AF%94& page=1&page_size=20 &publish_timestamp=0 &scene=2&scene_type=95fen_android_search_personal&sn=SearchList 阅读详情

题目地址:http://codeforces.com/contest/479

这次自己又只能做出4道题来。

A题:Expression

水题。

枚举六种情况求最大值即可。

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
#define LL __int64
int main()
{
    LL a, b, c, d[10];
    while(scanf("%I64d%I64d%I64d",&a,&b,&c)!=EOF)
    {
        d[0]=a*b*c;
        d[1]=(a+b)*c;
        d[2]=a+b+c;
        d[3]=a*(b+c);
        d[4]=a+b*c;
        d[5]=a*b+c;
        sort(d,d+6);
        printf("%I64d\n",d[5]);
    }
    return 0;
}

B题: Towers

水题。

每次都是将最多的拿出一个给最少的,直到最大的与最少的相差小于或等于1.

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
#define LL __int64
struct node
{
    int x, num;
}fei[1000];
int cmp(node x, node y)
{
    return x.x<y.x;
}
int a[2000], b[2000];
int main()
{
    int n, m, i, j, cnt, ans;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(i=0;i<n;i++)
        {
            scanf("%d",&fei[i].x);
            fei[i].num=i;
        }
        cnt=0;
        while(m--)
        {
            sort(fei,fei+n,cmp);
            if(fei[n-1].x-fei[0].x<=1) break;
            a[cnt]=fei[n-1].num;
            b[cnt++]=fei[0].num;
            fei[n-1].x--;
            fei[0].x++;
        }
        sort(fei,fei+n,cmp);
        printf("%d %d\n",fei[n-1].x-fei[0].x, cnt);
        for(i=0;i<cnt;i++)
        {
            printf("%d %d\n",a[i]+1,b[i]+1);
        }
    }
    return 0;
}

C题: Exams

还是水。。小贪心

小贪心。先按标记日期排个序,然后扫一遍即可,能用小的就优先考虑小的。

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
#define LL __int64
struct node
{
    int x, y;
}fei[6000];
int cmp(node x, node y)
{
    if(x.x==y.x)
        return x.y<y.y;
    return x.x<y.x;
}
int main()
{
    int n, i, j, ans, k, x1, x2;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<n;i++)
        {
            scanf("%d%d",&fei[i].x,&fei[i].y);
        }
        sort(fei,fei+n,cmp);
        k=1;
        for(i=0;i<n;i++)
        {
            if(fei[i].y>=k)
            {
                k=fei[i].y;
            }
            else
            {
                k=fei[i].x;
            }
        }
        printf("%d\n",k);
    }
    return 0;
}

D题:

还是水。。。。二分。

分别考虑4种情况,x,y,x+y,y-x。然后用二分找差值为这四个数的。

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
#define LL __int64
int a[110000];
int bin_search(int x, int y, int high)
{
    int low=0, mid;
    while(low<=high)
    {
        mid=low+high>>1;
        if(y-a[mid]==x) return 1;
        else if(y-a[mid]>x) low=mid+1;
        else high=mid-1;
    }
    return 0;
}
int main()
{
    int n, l, x, y, i, j, k, flag1, flag2;
    while(scanf("%d%d%d%d",&n,&l,&x,&y)!=EOF)
    {
        flag1=flag2=0;
        for(i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
            if(a[i]==x)
                flag1=1;
            if(a[i]==y)
                flag2=1;
        }
        if(flag1&&flag2)
        {
            printf("0\n");
        }
        else
        {
            flag1=flag2=0;
            for(i=1;i<n;i++)
            {
                if(bin_search(x,a[i],i-1))
                {
                    flag1=1;
                    break;
                }
            }
            for(i=1;i<n;i++)
            {
                if(bin_search(y,a[i],i-1))
                {
                    flag2=1;
                }
            }
            if(flag1&&flag2)
            {
                printf("0\n");
            }
            else if(flag1) printf("1\n%d\n",y);
            else if(flag2) printf("1\n%d\n",x);
            else
            {
                int flag=0;
                for(i=1;i<n;i++)
                {
                    if(bin_search(y+x,a[i],i-1))
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag)
                {
                    printf("1\n%d\n",a[i]-x);
                }
                else
                {
                    flag=0;
                    for(i=1;i<n;i++)
                    {
                        if(bin_search(y-x,a[i],i-1)&&(a[i]-y>=0||a[i]+x<=l))
                        {
                            flag=1;
                            break;
                        }
                    }
                    if(flag&&a[i]-y>=0)
                    {
                        printf("1\n%d\n",a[i]-y);
                    }
                    else if(flag&&a[i]+x<=l)
                    {
                        printf("1\n%d\n",a[i]+x);
                    }
                    else
                    {
                        printf("2\n%d %d\n",x,y);
                    }
                }
            }
        }
    }
    return 0;
}



ubuntu20.04 终端安装claude 【代码】ubuntu20.04 终端安装claude。 阅读详情

相关推荐

1.毫米波雷达心率、呼吸原理实现(一)实例

毫米波雷达心率、呼吸检测原理本项目分两到三篇文章写完,第一阶段借鉴TI开源项目以及根据自己的见解适当更改信号处理链通过AWR1843汽车雷达传感器和DCA1000采集卡采集数据完成人体呼吸和心跳检测算法的实现。第二阶段将仿真成功的代码搬移TIAWR1843传感器并通过串口数据实现生命体征的实时处理。本文即为第一阶段实现过程。本文首先概述毫米波雷达呼吸心跳检测的原理,紧接着概述本项目信号处理流程,另外本项目第一阶段通过matlab仿真验证算法的有效性,仿真源码可关注小编并私信可取。1.概述。

Poulen的博客 2万+

Codeforces274B

Codeforces274B 做法:树形dp,\(up[u]\)至少加多少次, \(down[u]\) 至少减多少次可以消去u这棵子树 转移:首先\(up[u] = max(up[v]), down[u] = max(down[u])\),因为为了消除整颗子树一定要选最多的次数才能消完,那么现在这个节点的\(a[u] = a[u] - down[u] + up[u]\),然后如果\(a...

dehukun0483的博客 494

关于LIO-SAM编译时出现错误 /usr/bin/ld: 找不到 -lBoost::timer

关于LIO-SAM编译时出现错误: 下载LIO-SAM代码 进入LIO-SAM文件夹,通过以下代码编译: mkdir build cd build cmake .. make 报错: /usr/bin/ld: 找不到 -lBoost::timer collect2: error: ld returned 1 exit status CMakeFiles/lio_sam_imuPreintegration.dir/build.make:759: recipe for target 'devel/lib/li

wwtx的博客 3652

Codeforces Round #274 (Div. 2)

Codeforces Round #274 (Div. 2)

逍遥小章 1634

pyautogui库详细教程,逐行注释(附项目实战:基于图像识别实现崩坏星穹铁道自动化测试)

本文包含了pyautogui的使用方法与常见问题指南,随文附带对游戏实现的自动化项目源码与说明文档

m0_53043024的博客 1万+

华为设备有关用户名密码的策略配置

命令用来开启对密码进行复杂度检查功能,设备默认已经是开启状态。1、密码长度大于等于12位,含数字大小写字母和特殊符号。2、设置密码更换周期为90天。取值范围8-16,默认长度为8位。登录失败后锁定时间大于15分钟。3、登录失败次数小于5次。4、登录超时30分钟以内。

简单的创作,希望可以帮助到跟我一样的学习者! 7853

【codeforces 274B】【树形DP】 B. Zero Tree【一棵树,每个点有权值,每次操作可以对一个联通子集中的点全部加或者减1,且每次操作必须包含点1,问最少多少次操作权值全为0】

传送门:B. Zero Tree 描述: B. Zero Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A tree is a graph w

魔笛手的博客 1659

debian mirrors 镜像源 riscv 64 赛昉 星光 starfive vf2 InRelease‘ doesn‘t support architecture ‘riscv64‘

debian mirrors 镜像 riscv 64 赛昉 星光2 starfive vf2 InRelease' doesn't support architecture 'riscv64'

qq_29758759的博客 1263

CodeForces - 274B Zero Tree

http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值。 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连通图)且这颗树中必须包含节点1 然后将这颗子树中的所有点的点权+1或-1 求把所有点权全部变为0的最小次数(n<=10^5) 题解:    因为每一次的子树中都必须有1,所以我们得知每一...

weixin_30814329的博客 280

手把手教你玩转服务器芯片架构--​​7.1 项目1:基于FPGA的RISC-V软核设计(Verilog实现核心指令执行单元)​

本文介绍了基于FPGA的RISC-V软核设计实践项目。项目采用Verilog实现RV32I指令集核心处理器,包含指令解码、ALU、寄存器堆等关键模块设计,并通过功能仿真验证。在Xilinx Artix-7 FPGA上完成综合与部署,资源利用率控制在5%以内。最后探讨了五级流水线优化、指令集扩展等进阶方案。该实践完整覆盖了从指令集设计、RTL实现到FPGA部署的全流程,可作为学习处理器架构与FPGA开发的典型案例。

MHD0815的博客 184

基于近邻列表法的团簇识别与冷凝成核分析(Matlab+Ovito)

本文将介绍如何使用Matlab和Ovito软件进行近邻列表法的团簇识别和冷凝成核分析,并提供相应的源代码。Ovito还提供了丰富的可视化功能,如颗粒渲染、团簇着色、团簇大小统计等,方便我们对冷凝成核现象进行可视化分析。通过使用Matlab和Ovito软件,我们可以方便地进行团簇识别和冷凝成核分析,并对系统中的冷凝行为进行研究和可视化展示。通过识别团簇,我们可以分析系统中的冷凝成核现象,即小团簇的形成和演化过程。通过统计团簇的大小,我们可以得到团簇大小大于等于10的团簇数目,这被认为是冷凝成核的现象。

NoerrorCode的博客 463

codeforces Round #274(div2) B解题报告

B. Towers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you know, all the kids in Berland love playing

旅行者西瓜 901

详解大端模式和小端模式

详解大端模式和小端模式 一、大端模式和小端模式的起源         关于大端小端名词的由来,有一个有趣的故事,来自于Jonathan Swift的《格利佛游记》:Lilliput和Blefuscu这两个强国在过去的36个月中一直在苦战。战争的原因:大家都知道,吃鸡蛋的时候,原始的方法是打破鸡蛋较大的一端,可以那时的皇帝的祖父由于小时侯吃鸡蛋,按这种方法把手指弄破了,因此他的父亲,就下令,命令

ce123的技术博客 19万+

codeforces Round #274(div2) C解题报告

C. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Student Valera is an undergraduate student at the U

旅行者西瓜 802

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

codeforces Round #274(div2) A解题报告

A. Expression time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya studies in a school and he adores Maths.

旅行者西瓜 925

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

codeforces Round #274(div2) E解题报告

首先明确一点,如若a < b,则无论如何都不可能乘坐到大于b的那一部分,反之亦然。 采用动态规划策略,这里我们可以以i为乘坐了i次,j为哪一层电梯。f[i][j] = sum(f[i-1][m]) - f[i-1][j],这里的m为满足条件的上一个楼层(设上一个楼层为x |x-j| < |x-b| )。这里的时间复杂度为O(k*n*n); 我们可以发现,m为一段连续区间,我们就可以用sum先累积起来,这里就直接简化为O(1),总的时间复杂度为O(k*n)。(PS: 注意m的边界)

旅行者西瓜 921

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

codeforces Round #274(div2) D解题报告

这题,我们必然需要查询某个数,这里我们可以让ai单调(题目已经预设是单调的),然后采用二分来查询,这样,每次查询只需要O(logn)的时间复杂度,这是本题的基本的核心。 由题意可知,标记增加量可能为:0, 1, 2; 为0个的时候: 则x和y都可以在尺子上找到,即a[i]+x和a[i]+y均可在尺子上找到,我们可以采用二分搜索。复杂度为O(nlogn); 为1个的时候: 第一种情况:x或y其中一个可以在尺子上找到; 第二种情况:可以找到组合点,即 a[i]+

旅行者西瓜 1253

Codeforces Round #274 (Div. 2) 解题报告 (C D E)

C. Exams 思路:tan

A Cube Master 617

Codeforces Round #274(Div.2) 题解

Codeforces Round #274 (Div.2) A.Expression Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integer...

404 Not Found 458

codeforces Round #272(div2) B解题报告

B. Dreamoon and WiFi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dreamoon is standing at the position 0 

旅行者西瓜 817

Codeforces Round #274 (Div. 2) C. Exams (贪心)

A. Exams Time Limit: 1 Sec   Memory Limit: 256 MB Description Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exam

滴水穿石,慢慢积累,总会有成果 676

Codeforces Round #274 (Div. 2) D

题目链接:http://codeforces.com/contest/479/problem/D 这道题目是练习set的好题

ThinkingLion的专栏 435
上一篇: HDU 1074 Doing Homework(状压DP)
下一篇: Codeforces Round #274 (Div. 2) E题:Riding in a Lift(DP)
Aerolite坠落
博客等级 码龄13年 203粉丝 640原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值