Boy or Girl CodeForces - 236A
如果一个人的用户名中不同的字符数是奇数,那么他就是一个男性,否则她就是一个女性(鬼知道为什么)。给你一个表示用户名的字符串,请帮助小A确定这个用户的性别。
即判断出是女生,打印 CHAT WITH HER!;判断出是男生,打印 IGNORE HIM!。
数据保证输入的字符都是小写字母!
Sample Input
wjmzbmr
xiaodao
sevenkplus
Sample Output
CHAT WITH HER!
IGNORE HIM!
CHAT WITH HER!
分析
统计不同元素的数量,开标记数组 或者 set。
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+10,INF=0x3f3f3f3f;
string s;
int a[26]={0}, ans=0;
void slove2(){
set<char> ss;
for(auto u : s) ss.insert(u);
ans=ss.size();
}
int main(){
// freopen("data.in", "r", stdin);
while(cin>>s){
memset(a, 0, sizeof(a)), ans=0;
for(int i=0; i<s.size(); i++) a[s[i]-'a']++;
for(int i=0; i<26; i++) if(a[i]) ans++;
if(ans&1) cout<<"IGNORE HIM!"<<endl;
else cout<<"CHAT WITH HER!"<<endl;
}
return 0;
}
标签:Boy,HER,int,CodeForces,CHAT,ans,Girl
From: https://www.cnblogs.com/hellohebin/p/16720855.html