蓝桥杯15届省C

server/2025/3/17 9:31:55/

洛谷P10904挖矿

#include<bits/stdc++.h>
using namespace std;
int n, m;
const int N = 2000010;
int l[N], r[N];
int cnt;
int main(){cin >> n >> m;for(int i = 1; i <= n; i++){int x; cin >> x;if(x > 0){r[x]++;}else if(x < 0){l[-x]++;}else cnt = 1;}for(int i = 1; i < N; i++){l[i] += l[i - 1];r[i] += r[i - 1];}int ans = 0;for(int i = 0; i <= m; i++){int ll = l[i];if(m - 2 * i > 0){ll += r[m - 2 * i];}ans = max(ans, ll);int rr = r[i];if(m - 2 * i > 0){rr += l[m - 2 * i];}ans = max(ans, rr);}cout << ans + cnt << endl;return 0;
} 

洛谷P

#include<bits/stdc++.h>
using namespace std;
int n;
bool check(string a, int cnt1, int cnt2){int l = cnt1, r = a.length() - 1 - cnt2;while(l < r){if(a[l] != a[r])return false;l++, r--;}return true;
}
bool check2(string b, string c){if(b.size() < c.size())return false;for(int i = c.size() - 1, j = b.size() - 1; i >= 0; i--, j--){if(c[i] != b[j])return false;} return true;
}
int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cin >> n;while(n--){string a; cin >> a;int cnt2 = 0, cnt1 = 0;string b = "";while(a[a.length() - 1 - cnt2] == 'l' || a[a.length() - 1 - cnt2] == 'q' || a[a.length() - 1 - cnt2] == 'b'){b += a[a.length() - 1 - cnt2];cnt2++;}string c = "";while(a[cnt1] == 'l' || a[cnt1] == 'q' || a[cnt1] == 'b'){c += a[cnt1];cnt1++;}if(check(a, cnt1, cnt2) && check2(b, c))cout << "Yes" << endl;else cout << "No" << endl;}return 0;
} 


http://www.ppmy.cn/server/175673.html

相关文章

[WEB开发] Web基础

一. HTTP 在之前的文章中, 我们已经详细学习过HTTP了. [计算机网络] HTTP/HTTPS 二. Web基础 2.1 spring全家桶 spring framework: spring最底层的框架. Spring Framework 是一个功能强大的 Java 应用程序框架&#xff0c;旨在提供高效且可扩展的开发环境。它结合了轻量级…

ISP--Gamma Correction

文章目录 现象Gamma产生的原因CRT属性导致人眼的亮度特性 gamma校正LUT法线性插值法模拟gamma法 现象 从上往下看左侧黑色块黑得越来越严重&#xff0c;对比度也在逐渐加深。此时灰阶的高亮区获得的数据位变少&#xff0c;暗区获得的数据位变多&#xff0c;暗区细节会更多。但是…

Authenticity is the compass that guides you to your true purpose

Title: The Strength of Being Unapologetically You In a world that constantly pressures us to conform, authenticity becomes an act of rebellion. Your uniqueness is not a flaw—it is your superpower. When you silence the noise of others’ expectations and li…

Vue-Lottie动画使用

Vue-Lottie 是一个基于 Vue.js 的库&#xff0c;用于在 Vue 应用程序中渲染 Adobe After Effects 动画&#xff0c;通过 Bodymovin 插件导出的 JSON 数据来实现。这个项目非常适合那些想要在他们的Vue项目中加入精美动画而又不希望因为视频文件或 GIF 图片而增加应用大小的开发…

信息系统运行管理员教程6--信息系统安全

信息系统运行管理员教程6–信息系统安全 第1节 信息系统安全概述 1.信息系统安全的概念 信息系统安全是指保障计算机及其相关设备、设施&#xff08;含网络&#xff09;的安全&#xff0c;运行环境的安全&#xff0c;信息的安全&#xff0c;实现信息系统的正常运行。信息系统…

es6初步学习

Es6 作用&#xff1a; 语法简洁&#xff0c;功能丰富框架开发应用前端开发职位要求 ECMAScript 它是一个脚本程序设计语言注意&#xff1a;块级作用域是指变量只在特定的代码块&#xff08;通常由一对花括号{}包裹&#xff0c;比如if语句、for循环、while循环等的代码块 &a…

国产编辑器EverEdit - Hex Dump插件:看到文本的另一面!

1 Hex Dump插件 1.1 应用场景 有时可能需要显示字母的ASCII编码&#xff0c;或其他文字的字节编码&#xff0c;可以使用Hex Dump插件来完成 1.2 使用方法 安装Hex Dump插件&#xff0c;安装插件方法参考&#xff1a;扩展管理 在编辑器中选中文本&#xff0c;选择扩展 -> …

[JAVASE] Collection集合的遍历

一. 集合分类 java中的Collection集合分为两类, 分别是单列集合(List)和双列(Map)集合. 1.1 单列集合 1.2 双列集合 二. 集合遍历 2.1 List单列集合的遍历 for each遍历 迭代器遍历 lambda遍历 2.2 Map双列集合的遍历 for each遍历 k-v整体遍历 lambda表达式遍历