第三届传智杯全国大学生IT技能大赛(决赛B组)【c++】
生活随笔
收集整理的这篇文章主要介绍了
第三届传智杯全国大学生IT技能大赛(决赛B组)【c++】
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
https://www.luogu.com.cn/contest/42328
目录
- T172096 课程
- T172097 序列
- T172098 子串
- T172099 打牌
- T172100 商店
T172096 课程
https://www.luogu.com.cn/problem/T172096?contestId=42343
T172097 序列
https://www.luogu.com.cn/problem/T172097?contestId=42343
T172098 子串
https://www.luogu.com.cn/problem/T172098?contestId=42343
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; int n; int a,b; int ans; string s1,s2; int main(void) {cin>>n;for(int i=0;i<n;i++){ans=0;cin>>a>>b;cin>>s1>>s2;for(int i=0;i<s1.size();i++) s1[i]=tolower(s1[i]); for(int i=0;i<s2.size();i++) s2[i]=tolower(s2[i]); for(int i=0;i<=(b-a);i++){string s3=s2.substr(i,a);if(s3==s1) ans++;}cout<<ans<<endl;} }T172099 打牌
https://www.luogu.com.cn/problem/T172099?contestId=42343
代码是转载自:https://blog.csdn.net/Niklaus_Mikael/article/details/115292810
#include<iostream> using namespace std; int n,m; int have[5][55]; int used[5];//使用的排数 int game() {int player=0,stop=0,num=0,id=0;//选手编号 while(1){int cando=0;int i,j;for(i=1;i<=n;i++)//一次打几张牌 { if(i>=num){for(j=1;j<=m;j++)if((have[player][j]>=i)&&((i==num&&j>id)||i>num)){cando=1;break;}if(cando)break;}} if(cando==0)//打了一轮了,重新初始化 。 {stop+=1;if(stop==2)//俩人不能接牌 {num=0;id=0;stop=0;}}else//可以打 {stop=0;have[player][j]-=i;used[player]+=i;if(used[player]==n)//牌打完了 {return player+1;}num=i;//牌的大小 id=j;//牌的张数 }player=(player+1)%3;} } int main(void) {cin>>n>>m;for(int i=0;i<3;i++)for(int j=1,t;j<=n;j++){cin>>t;have[i][t]+=1;}cout<<game()<<endl;return 0; }T172100 商店
https://www.luogu.com.cn/problem/T172100?contestId=42343
总结
以上是生活随笔为你收集整理的第三届传智杯全国大学生IT技能大赛(决赛B组)【c++】的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 第三届“传智杯”全国大学生IT技能大赛(
- 下一篇: 第十二届蓝桥杯大赛软件赛省赛第二场【C+