CSP-J 2024 T1 扑克牌
这道题比赛是有人188行else if过了
于是我哭笑不得的写下这篇题解
先说一下思路:
思路一:记录已获得的牌数去重后输出
缺点:太费时间
思路二:用bool数组标记,cnt记录,输出52-cnt;
优点:不费时间可以省时间来做T4虽然我T4最后还是没写完
上代码
#include<bits/stdc++.h>
using namespace std;
char a[5];//记录输入的牌
bool bo[205][205];//标记牌(用来去重)
signed main(){
int n;
int ans=0;//记录从小Q借来的牌数(已去重)
cin>>n;
for(int i=1;i<=n;i++){
cin>>a;
if(bo[(int)a[0]][(int)a[1]]==0){
bo[(int)a[0]][(int)a[1]]=1;//标记
ans++;
}
}
cout<<52-ans;//还要借的牌数
return 0;
}