第三届传智杯全国大学生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技能大赛(
- 下一篇: 第六章:双指针,BFS,和图论 【完结】