ccfcsp-202406(1、2、3、4、5)

server/2024/9/22 10:22:50/

矩阵重塑(其一)

#include <bits/stdc++.h>
using namespace std;
int main() {int n,m,p,q;cin >> n >> m >> p >> q;vector<int> vec(n * m);vector<vector<int>> res(p, vector(q,0));int k = 0;for(int i = 0; i < n; i++){for(int j = 0; j < m; j++){cin >> vec[k++];}}k = 0;for(int i = 0; i < p; i++){for(int j = 0; j < q; j++){res[i][j] = vec[k++];}}for(int i = 0; i < p; i++){for(int j = 0; j < q; j++){cout << res[i][j] << " ";}cout << endl;}return 0;
}

矩阵重塑(其二)

#include <bits/stdc++.h>
using namespace std;
int main() {int n,m,t;cin >> n >> m >> t;vector<vector<int>> res(10000, vector<int>(10000,0));for(int i = 0; i < n; i++){for(int j = 0; j < m; j++){cin >> res[i][j];}}int k = 0;vector<int> one(n * m);for(int i = 0; i < n; i++){for(int j = 0; j < m; j++){one[k++] = res[i][j];}}for(int i = 0; i < t; i++){int op,a,b;cin >> op >> a >> b;if(op == 1){k = 0;n = a,m = b;for(int l = 0; l < n; l++){for(int j = 0; j < m; j++){res[l][j] = one[k++];}}k = 0;for(int l = 0; l < n; l++){for(int j = 0; j < m; j++){one[k++] = res[l][j];}}}else if(op == 2){k = 0;swap(n,m);for(int l = 0; l < m; l++){for(int j = 0; j < n; j++){res[j][l] = one[k++];}}k = 0;for(int l = 0; l < n; l++){for(int j = 0; j < m; j++){one[k++] = res[l][j];}}}else if(op == 3){cout << res[a][b] << endl;}}return 0;
}

文本分词

#include <bits/stdc++.h>
using namespace std;
int main() {int n,m;cin >> n >> m;unordered_map<string,int> mp;set<string> st;unordered_map<string,int> mmp;for(int i = 0; i < n; i++){string s;int f;cin >> s >> f;mp[s] = f;for(int j = 0; j < s.size(); j++){st.insert(string(1,s[j]));if(j != s.size() - 1){string str = string(1,s[j]) + "-" + string(1,s[j+1]);mmp[str] += f;}}}int maxx = 0;string str;for(auto it : mmp){if(maxx < it.second){maxx = it.second;str = it.first;}}str.erase(str.find('-'),1);for(auto c : st){cout << c << endl;m--;if(m <= 0)break;}if(m > 0)cout << str << endl;return 0;
}

货物调度

#include <bits/stdc++.h>
using namespace std;
int res = INT_MAX;
int n,m,v;
vector<pair<int,int>> warehouse(1001);//基本费用 计件费用
vector<pair<int,int>> goods(1001);//现金 仓库号
unordered_set<int> path;//记录从几号仓库出货
void backtracking(int cash,int cost,int index){if(cost >= res)return;if(cash - cost >= v){res = min(res, cost);return;}for(int i = index; i < m; i++){int id = goods[i].second;//仓库号if(path.find(id) == path.end()){path.insert(id);backtracking(cash + goods[i].first, cost + warehouse[id].first + warehouse[id].second,i + 1);path.erase(id);}else{backtracking(cash + goods[i].first, cost + warehouse[id].second,i + 1);}}
}
int main() {cin >> n >> m >> v;for(int i = 0; i < n; i++){cin >> warehouse[i].first >> warehouse[i].second;}for(int i = 0; i < m; i++){cin >> goods[i].first >> goods[i].second;}backtracking(0,0,0);cout << res;return 0;
}

哥德尔机

#include <bits/stdc++.h>
using namespace std;
int main() {int n,m;vector<vector<int>> V(10000,vector<int>(10000, 0));cin >> n >> m;int x1,x2,y1,y2,v;for(int i = 0; i < n; i++){cin >> x1 >> x2 >> y1 >> y2 >> v;for(int j = x1; j <= x2; j++){for(int k = y1; k <= y2; k++){V[j][k] = v + max(V[j][k] - v, 0);}}}for(int i = 0; i < m; i++){cin >> x1 >> x2 >> y1 >> y2;int res = 0;for(int j = x1; j <= x2; j++){for(int k = y1; k <= y2; k++){res = max(res, V[j][k]);}}cout << res << endl;}return 0;
}

最后得分
在这里插入图片描述


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

相关文章

Spring系统学习(一)——初识Spring框架

1. Spring 框架概述 1.1 什么是 Spring&#xff1f; Spring 是一个流行的基于 Java 的开源框架&#xff0c;旨在简化企业级应用程序的开发。最初&#xff0c;它是为了简化 Java 企业版&#xff08;Java EE&#xff09;的复杂性而设计的&#xff0c;经过不断发展&#xff0c;S…

使用 NCache 将 Java 微服务扩展到极致性能

微服务已成为软件开发领域的一种变革性架构方法&#xff0c;提供了从整体结构到更加模块化和可扩展的系统的范式转变。微服务的核心是将复杂的应用程序分解为更小的、可独立部署的服务&#xff0c;这些服务可以无缝通信&#xff0c;从而提高敏捷性、灵活性和易维护性。这种分散…

由于安全风险,安全领导者考虑禁止人工智能编码

安全团队与开发团队之间的紧张关系 83% 的安全领导者表示&#xff0c;他们的开发人员目前使用人工智能来生成代码&#xff0c;57% 的人表示这已成为一种常见做法。 然而&#xff0c;72% 的人认为他们别无选择&#xff0c;只能允许开发人员使用人工智能来保持竞争力&#xff0…

分享一个爬虫数据挖掘 农村产权交易数据可视化平台 数据分析大数据 Java、python双版(源码、调试、LW、开题、PPT)

&#x1f495;&#x1f495;作者&#xff1a;计算机源码社 &#x1f495;&#x1f495;个人简介&#xff1a;本人 八年开发经验&#xff0c;擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等&#xff0c;大家有这一块的问题可以一起交流&…

【Unity与数据库01】开发者如何选择数据库

在选择数据库时&#xff0c;需要考虑多个因素&#xff0c;包括项目的规模、性能需求、开发团队的熟悉程度、维护成本等。以下是对 MySQL、Oracle 和 SQLite 的简要比较&#xff0c;以帮助你决定哪个更适合你的 Unity 游戏项目。 1. SQLite 优点&#xff1a; 轻量级&#xff1…

字符串函数(2)

目录 前言1. strlen1.1 strlen函数的理解和使用1.2 strlen函数的模拟实现 2. strcpy2.1 strcpy函数的理解和使用2.2 strcpy函数的模拟实现 3.strcat3.1 strcat函数的理解和使用3.2 strcat 函数的模拟实现 前言 在上一篇文章中&#xff0c;我们对字符分类函数和字符转换函数进行…

云服务器docker中Hbase整合java-api需要放行的接口

在使用 Docker 部署 HBase 并通过 Java API 进行访问时&#xff0c;确保通信畅通非常重要。如果 HBase 部署在云服务器或虚拟机中&#xff0c;你需要在云服务器的安全组中放行一些关键端口&#xff0c;确保外部或本地的 Java 应用可以正确访问 Docker 容器中的 HBase 服务。 1…

基于Spring Boot的Java免税商品优选商城设计

第一章 绪论 1.1 课题开发的背景 从古至今&#xff0c;通过书本获取知识信息的方式完全被互联网络信息化&#xff0c;但是免税商品优选购物商城&#xff0c;对于购物商城工作来说&#xff0c;仍然是一项非常重要的工作。尤其是免税商品优选购物商城&#xff0c;传统人工记录模式…