您的位置:首页 > 房产 > 家装 > 软件开发代码大全_桐乡网站设计公司_做推广哪个平台好_免费收录网站

软件开发代码大全_桐乡网站设计公司_做推广哪个平台好_免费收录网站

2024/10/5 22:32:30 来源:https://blog.csdn.net/weixin_51503393/article/details/142422572  浏览:    关键词:软件开发代码大全_桐乡网站设计公司_做推广哪个平台好_免费收录网站
软件开发代码大全_桐乡网站设计公司_做推广哪个平台好_免费收录网站

矩阵重塑(其一)

#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;
}

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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com