蒟蒻的第24次CCF计算机软件能力认证

2024-02-27 12:58

本文主要是介绍蒟蒻的第24次CCF计算机软件能力认证,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

100+70+40+25+0,没有技巧全是感情www!

目录

  • 202112-1 序列查询
  • 202112-2 序列查询新解
  • 202112-3 登机牌条码
  • 202112-4 磁盘文件操作
  • 202112-5 极差路径

202112-1 序列查询

这题一开始没有照题目的暗示,拿到50,后来根据题目的优化方法优化就可以了

#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>
#include <limits.h>
using namespace std;
const int maxn = 210;
int A[maxn];
int main()
{int n, N;int t = 0;long long ans = 0;int count = -1;scanf("%d %d",&n,&N);int i,j;j = 0;A[0] = 0;for (i = 1; i <= n; i++) {scanf("%d",&A[i]);}for (i = 0; i <= N-1; i++){for (; j <= n; j++){if (A[j] > i)break;}ans += j - 1;}printf("%lld\n",ans);return 0;
}

202112-2 序列查询新解

#include<bits/stdc++.h>
using namespace std;#define M 500000+2
#define LL long long
inline LL read(){LL x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;
}
LL n,m,nn;
LL a[M];
typedef struct NODE{LL s,e;LL num;NODE(){};NODE(LL ss,LL ee,LL numm):s(ss),e(ee),num(numm){};
}node;
node g[M],f[M];
int main(){scanf("%lld%lld",&n,&nn);LL gi=0,fi=0;a[1]=read();f[fi++]=NODE(0,a[1]-1,0);for (register LL i=2;i<=n;i++){a[i]=read();f[fi++]=NODE(a[i-1],a[i]-1,i-1);}f[fi]=NODE(a[n],nn-1,n);LL r=floor(nn/(n+1));LL j=1,tmp;for (LL i=r,k=1;i<=nn-1;i+=r,k++){g[gi++]=NODE(i-r,i-1,k-1);j=i;tmp=k;}g[gi]=NODE(j,nn-1,tmp);LL ans=0,i=0,last=0;j=0;while (i<=fi&&j<=gi){LL right=min(f[i].e,g[j].e);//    cout<<right<<' ';ans+=abs(f[i].num-g[j].num)*(right-last);last=right;//    cout<<last<<endl;if (right==f[i].e) i++;if (right==g[j].e) j++;}printf("%lld\n",ans);return 0;
}

202112-3 登机牌条码

只考虑了最简单的-1的情况,用vector存放数字。

#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <map>
#include <string>
#include<cstring>
#include <algorithm>
#include <sstream>
#include <vector>
#include <limits.h>
using namespace std;
const int maxn = 1010;
vector<int> mazi;
vector<int> ans;
char a[maxn];
int main()
{int w, s;scanf("%d %d", &w, &s);scanf("%s", a);int i, j;int len = strlen(a);int flag;//flag表示当前的模式,flag=0表示大写,=1表示小写,=2表示数字flag = 0;for (i = 0; i < len; i++){if (a[i] >= 'A' && a[i] <= 'Z'){if (flag == 1)//表示之前是小写模式{mazi.push_back(28);mazi.push_back(28);flag = 0;}else if (flag == 2)//表示之前是数字模式{mazi.push_back(28);flag = 0;}mazi.push_back(a[i] - 'A');}else if (a[i] >= 'a' && a[i] <= 'z'){if (flag == 0)//大写模式{mazi.push_back(27);flag = 1;}else if (flag = 2)//数字模式{mazi.push_back(28);flag = 1;}mazi.push_back(a[i] - 'a');}else if (a[i] >= '0' && a[i] <= '9'){if (flag == 0){mazi.push_back(28);flag = 2;}else if (flag == 1)//小写{mazi.push_back(28);flag = 2;}mazi.push_back(a[i] - '0');}}if (mazi.size() % 2 == 1)//表示是偶数{mazi.push_back(29);}ans.push_back(0);for (i = 0; i < mazi.size(); i = i + 2){ans.push_back(mazi[i] * 30 + mazi[i + 1]);}if (ans.size() % w == 0){ans[0] = ans.size();}else{int temp = w - ans.size() % w;for (j = 1; j <= temp; j++){ans.push_back(900);}ans[0] = ans.size();}for (i = 0; i < ans.size(); i++){printf("%d\n", ans[i]);}return 0;
}

202112-4 磁盘文件操作

本来想用结构体,但是结构体的内存超限了,所以用了map,都用位置sta(tion)作为索引即可。

#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>
#include <limits.h>
using namespace std;
map<int, int> sta2id;//sta位置的id号
map<int, int> sta2num;//sta位置的数字
map<int, int> sta2preid;//sta位置的前id号
int main()
{int n, m, k;scanf("%d %d %d",&n,&m,&k);//读取n,m,kint i, j;//循环变量int caozuo;//操作int id,l, r, x,p;int flag;//首先初始化for (i = 1; i <= m; i++){sta2id[i] = 0;//位置对应的id号为0}for (i = 0; i < k; i++){scanf("%d",&caozuo);if (caozuo == 0){scanf("%d %d %d %d",&id,&l,&r,&x);for (j = l; j <= r; j++){if (sta2id[j] != id && sta2id[j] != 0)break;else{sta2id[j] = id;sta2num[j] = x;}                   }if (j == l)printf("-1\n");elseprintf("%d\n",j-1);}else if (caozuo == 1)//删除{scanf("%d %d %d", &id, &l, &r);flag = 0;for (j = l; j <= r; j++){if (sta2id[j] != id){flag = 1;break;}}if (flag == 1){printf("FAIL\n");}else{for (j = l; j <= r; j++){sta2id[j] = 0;//占有的id变成0;sta2preid[j] = id;//preid变为id}printf("OK\n");}}else if (caozuo == 2){scanf("%d %d %d", &id, &l, &r);flag = 0;for (j = l; j <= r; j++){if (sta2id[j] != 0 || sta2preid[j] != id){flag = 1;break;}}if (flag == 1){printf("FAIL\n");}                else{for (j = l; j <= r; j++){sta2id[j] = id;}printf("OK\n");}}else if (caozuo == 3){scanf("%d",&p);if (sta2id[p] == 0){printf("0 0\n");}else{printf("%d %d\n",sta2id[p],sta2num[p]);}}}return 0;
}

202112-5 极差路径

这篇关于蒟蒻的第24次CCF计算机软件能力认证的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/752472

相关文章

java如何通过Kerberos认证方式连接hive

《java如何通过Kerberos认证方式连接hive》该文主要介绍了如何在数据源管理功能中适配不同数据源(如MySQL、PostgreSQL和Hive),特别是如何在SpringBoot3框架下通过... 目录Java实现Kerberos认证主要方法依赖示例续期连接hive遇到的问题分析解决方式扩展思考总

浅析Spring Security认证过程

类图 为了方便理解Spring Security认证流程,特意画了如下的类图,包含相关的核心认证类 概述 核心验证器 AuthenticationManager 该对象提供了认证方法的入口,接收一个Authentiaton对象作为参数; public interface AuthenticationManager {Authentication authenticate(Authenti

EasyPlayer.js网页H5 Web js播放器能力合集

最近遇到一个需求,要求做一款播放器,发现能力上跟EasyPlayer.js基本一致,满足要求: 需求 功性能 分类 需求描述 功能 预览 分屏模式 单分屏(单屏/全屏) 多分屏(2*2) 多分屏(3*3) 多分屏(4*4) 播放控制 播放(单个或全部) 暂停(暂停时展示最后一帧画面) 停止(单个或全部) 声音控制(开关/音量调节) 主辅码流切换 辅助功能 屏

【Kubernetes】K8s 的安全框架和用户认证

K8s 的安全框架和用户认证 1.Kubernetes 的安全框架1.1 认证:Authentication1.2 鉴权:Authorization1.3 准入控制:Admission Control 2.Kubernetes 的用户认证2.1 Kubernetes 的用户认证方式2.2 配置 Kubernetes 集群使用密码认证 Kubernetes 作为一个分布式的虚拟

Science|癌症中三级淋巴结构的免疫调节作用与治疗潜力|顶刊精析·24-09-08

小罗碎碎念 Science文献精析 今天精析的这一篇综述,于2022-01-07发表于Science,主要讨论了癌症中的三级淋巴结构(Tertiary Lymphoid Structures, TLS)及其在肿瘤免疫反应中的作用。 作者类型作者姓名单位名称(中文)通讯作者介绍第一作者Ton N. Schumacher荷兰癌症研究所通讯作者之一通讯作者Daniela S. Thomm

【Shiro】Shiro 的学习教程(二)之认证、授权源码分析

目录 1、背景2、相关类图3、解析3.1、加载、解析阶段3.2、认证阶段3.3、授权阶段 1、背景 继上节代码,通过 debug 进行 shiro 源码分析。 2、相关类图 debug 之前,先了解下一些类的结构图: ①:SecurityManager:安全管理器 DefaultSecurityManager: RememberMeManager:实现【记住我】功能

CCF推荐C类会议和期刊总结(计算机网络领域)

CCF推荐C类会议和期刊总结(计算机网络领域) 在计算机网络领域,中国计算机学会(CCF)推荐的C类会议和期刊为研究者提供了广泛的学术交流平台。以下是对所有C类会议和期刊的总结,包括全称、出版社、dblp文献网址以及所属领域。 目录 CCF推荐C类会议和期刊总结(计算机网络领域) C类期刊 1. Ad Hoc Networks 2. CC 3. TNSM 4. IET Com

OpenStack离线Train版安装系列—3控制节点-Keystone认证服务组件

本系列文章包含从OpenStack离线源制作到完成OpenStack安装的全部过程。 在本系列教程中使用的OpenStack的安装版本为第20个版本Train(简称T版本),2020年5月13日,OpenStack社区发布了第21个版本Ussuri(简称U版本)。 OpenStack部署系列文章 OpenStack Victoria版 安装部署系列教程 OpenStack Ussuri版

OpenStack Victoria版——3.控制节点-Keystone认证服务组件

3.控制节点-Keystone认证服务组件 更多步骤:OpenStack Victoria版安装部署系列教程 OpenStack部署系列文章 OpenStack Victoria版 安装部署系列教程 OpenStack Ussuri版 离线安装部署系列教程(全) OpenStack Train版 离线安装部署系列教程(全) 欢迎留言沟通,共同进步。 文章目录 创建key

SIGMOD-24概览Part7: Industry Session (Graph Data Management)

👇BG3: A Cost Effective and I/O Efficient Graph Database in ByteDance 🏛机构:字节 ➡️领域: Information systems → Data management systemsStorage management 📚摘要:介绍了字节新提出的ByteGraph 3.0(BG3)模型,用来处理大规模图结构数据 背景