- [CSP-J 2024] 扑克牌
poker
- 2024-12-7 20:29:51 @
#include<bits/stdc++.h>
using namespace std;
string st;
int d[15],c[15],s[15],h[15];
int b(char c){
if(c=='A') return 1;
else if(c=='T') return 10;
else if(c=='J') return 11;
else if(c=='Q') return 12;
else if(c=='K') return 13;
else return c-'0';
}
int main(){
freopen("poker.in","r",stdin);
freopen("poker.out","w",stdout);
int n,t,ans=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>st;
if(st[0]=='D'){
t=b(st[1]);
d[t]=1;
}else if(st[0]=='C'){
t=b(st[1]);
c[t]=1;
}else if(st[0]=='H'){
t=b(st[1]);
h[t]=1;
}else if(st[0]=='S'){
t=b(st[1]);
s[t]=1;
}
}
for(int i=1;i<=13;i++){
if(d[i]==0) ans++;
if(c[i]==0) ans++;
if(h[i]==0) ans++;
if(s[i]==0) ans++;
}
cout<<ans;
return 0;
}
1 comments
-
张景 LV 6 @ 2024-12-7 20:30:32
#include<bits/stdc++.h> using namespace std; string st; int d[15],c[15],s[15],h[15]; int b(char c){ if(c=='A') return 1; else if(c=='T') return 10; else if(c=='J') return 11; else if(c=='Q') return 12; else if(c=='K') return 13; else return c-'0'; } int main(){ freopen("poker.in","r",stdin); freopen("poker.out","w",stdout); int n,t,ans=0; cin>>n; for(int i=0;i<n;i++){ cin>>st; if(st[0]=='D'){ t=b(st[1]); d[t]=1; }else if(st[0]=='C'){ t=b(st[1]); c[t]=1; }else if(st[0]=='H'){ t=b(st[1]); h[t]=1; }else if(st[0]=='S'){ t=b(st[1]); s[t]=1; } } for(int i=1;i<=13;i++){ if(d[i]==0) ans++; if(c[i]==0) ans++; if(h[i]==0) ans++; if(s[i]==0) ans++; } cout<<ans; return 0; } }
- 1
Information
- ID
- 2492
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 8
- Tags
- (None)
- # Submissions
- 85
- Accepted
- 11
- Uploaded By