欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 金融 > 2025“钉耙编程”中国大学生算法设计春季联赛(1)题解(更新中)

2025“钉耙编程”中国大学生算法设计春季联赛(1)题解(更新中)

2025/4/2 3:17:27 来源:https://blog.csdn.net/2301_80045122/article/details/146720276  浏览:    关键词:2025“钉耙编程”中国大学生算法设计春季联赛(1)题解(更新中)

1001

签到

#include <bits/stdc++.h>using namespace std;//#define int long long
#define endl '\n' 
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int,int>; const int N=1e5+5;void solve() {int n;cin >> n;string t,s;cin>>t;bool f=0;for(int i=1;i<=n;i++){cin>>s;if(s==t){cout<<i<<endl;f=1;}}if(!f){cout<<-1<<endl;}
}signed main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;while (t--) {solve();}return 0;
}/*
*                        _oo0oo_
*                       o8888888o
*                       88" . "88
*                       (| -_- |)
*                       0\  =  /0
*                     ___/`---'\___
*                   .' \\|     |// '.
*                  / \\|||  :  |||// \
*                 / _||||| -:- |||||- \
*                |   | \\\  - /// |   |
*                | \_|  ''\---/''  |_/ |
*                \  .-\__  '-'  ___/-. /
*              ___'. .'  /--.--\  `. .'___
*           ."" '<  `.___\_<|>_/___.' >' "".
*          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
*          \  \ `_.   \_ __\ /__ _/   .-` /  /
*      =====`-.____`.___ \_____/___.-`___.-'=====
*                        `=---='
* 
* 
*      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 
*            佛祖保佑       永不宕机     永无BUG
*/

1002

船长

1003

船舱

1004

海浪

1005

航线

1006

密码

 个数用哈希表存比较好(但是map过了)

#include <bits/stdc++.h>using namespace std;//#define int long long
#define endl '\n' 
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int,int>; const int N=1e5+5;void solve() {int n;cin >> n;vector<int>a(3);map<int,int>mp;for(int i=1;i<=n;i++){cin>>a[0]>>a[1]>>a[2];sort(a.begin(),a.end());do{if((a[0]-a[1])%a[2]==0){if((a[0]-a[1])/a[2]>=0)mp[(a[0]-a[1])/a[2]]++;}}while(next_permutation(a.begin(),a.end()));for(auto x:mp){if(x.second>=n){cout<<x.first<<endl;}}}
}signed main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;cin >> t;while (t--) {solve();}return 0;
}

1007

分配宝藏

1008

运输

1009

切割木材

1010

返航

版权声明:

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

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

热搜词