目录
一、题目
二、分析
二、1、骗分代码
我们可以知道至少有6个测试数据没有重复的牌,于是以下代码可以拿60分。
#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("poker.in","r",stdin);
freopen("poker.out","w",stdout);
int n;
cin>>n;
cout<<52-n;
fclose(stdin);
fclose(stdout);
return 0;
}
对于高手来说,这代码只需5秒。
但,分数是不是没Accepted 100分,只能Wrong Answer 60分。有没有满分呢?
二、2、Accepted代码
我们只需要加个输入string、map、cnt计数就ok了。
以下即为Accepted代码。
#include<bits/stdc++.h>
using namespace std;
map<string,bool>mp;
int main(){
freopen("poker.in","r",stdin);
freopen("poker.out","w",stdout);
int n,cnt=0;
cin>>n;
string a;
while(n--){
cin>>a;
if(!mp[a])cnt++,mp[a]=true;
}cout<<52-cnt;
fclose(stdin);
fclose(stdout);
return 0;
}
二、3、易爆0处
二、3、1、口诀巧查 一头二文三查中
一头:看函数名、头文件。
二文:看文件操作,有没有在最后加fclose。
三查中:检查中间的代码