A. Boy or Girl
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Description

Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very
often and eventually they became a couple in the network.

But yesterday, he came to see "her" in the real world and found out "she" is actually a very strong man! Our hero is very sad and he is too tired to love again now. So he came up with a way to recognize users' genders by their user names.

This is his method: if the number of distinct characters in one's user name is odd, then he is a male, otherwise she is a female. You are given the string that denotes the user name, please help our hero to determine the gender of this user by his method.

Input

The first line contains a non-empty string, that contains only lowercase English letters — the user name. This string contains at most 100 letters.

Output

If it is a female by our hero's method, print "CHAT WITH HER!" (without the quotes), otherwise, print "IGNORE HIM!" (without the quotes).

Sample Input

Input
wjmzbmr
Output
CHAT WITH HER!
Input
xiaodao
Output
IGNORE HIM!
Input
sevenkplus
Output
CHAT WITH HER!

Hint

For the first example. There are 6 distinct characters in "wjmzbmr". These characters are: "w", "j", "m",
"z", "b", "r". So wjmzbmr is a female and you should print "CHAT WITH HER!".

题目确实水啊,但如果用两层循环遍历可能很费时,虽然数据很小,很水。。介绍一种很好用的函数,这就是我写这篇博客的目的;

来看AC代码1;

<span style="font-family:KaiTi_GB2312;font-size:18px;color:#ff6666;">#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
char a[120];
scanf("%s",a);
int x=strlen(a);
sort(a,a+x);
int n=unique(a,a+x)-a;//一般与sort结合使用,字符也是可以排序的;
if(n%2)
printf("IGNORE HIM!\n");
else
printf("CHAT WITH HER!\n");
return 0;
}</span>

再看AC代码2:

#include<cstdio>//相比上面代码很麻烦吧,也很费时;
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
const int N=100+50;
char a[N],b[N];
int main()
{
int x,i,j,sum;
while(~scanf("%s",a))
{
x=strlen(a);
sum=0;
for(i=0; i<x; i++)
{
int f=0;
for(j=0; j<i; j++)
{
if(a[j]==a[i])
{
f=1;
break;
}
}
if(!f)
sum++;
}
if(sum%2)
printf("IGNORE HIM!");
else
printf("CHAT WITH HER!\n");
}
return 0;
}

unique()函数是一个去重函数,STL中unique的函数 unique的功能是去除相邻的重复元素(只保留一个),

还有一个容易忽视的特性是它并不真正把重复的元素删除。他是c++中的函数,所以头文件要加#include<iostream.h>,具体用法如下:



    int num[100];

   unique(num,mun+n)返回的是num去重后的尾地址,之所以说比不真正把重复的元素删除,其实是,该函数把重复的元素一到后面去了,然后依然保存到了原数组中,然后返回去重后最后一个元素的地址,因为unique去除的是相邻的重复元素,所以一般用之前都会要排一下序。

结合代码:

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <iostream>

#include <algorithm>

#include <time.h>

using namespace std;

int main()

{

int a[120];

for(int i=0;i<5;i++)

scanf("%d",&a[i]);

int n=unique(a,a+5)-a;//这里n就相当于是去重后不同元素的个数;

for(i=0;i<n;i++)

printf("%d ",a[i]);

printf("\n");

return 0;

}//可以自己试试看看输出结果;

『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 236A,虽然很水,但有一个很简单的函数用起来方便的更多相关文章

  1. 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 237C,素数打表,二分查找

    C. Primes on Interval time limit per test 1 second memory limit per test 256 megabytes input standar ...

  2. 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]CF-236B. Easy Number Challenge

    B. Easy Number Challenge time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  3. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]-最小内积(第八届北京师范大学程序设计竞赛决赛)

    H. 最小内积                                                                   Time Limit: 1000ms Memory ...

  4. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)

    A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]--Codeforces -35D. Animals

    D. Animals time limit per test 2 seconds memory limit per test 64 megabytes input input.txt output o ...

  6. K Simple question (第十届山东理工大学ACM网络编程擂台赛 正式赛)

    题解:素数筛+唯一分解定理 可以把素数筛那部分放到while之外,减小时间复杂度. #include <stdio.h> #include <stdlib.h> #includ ...

  7. F 阎小罗的Minimax (第十届山东理工大学ACM网络编程擂台赛 正式赛 )

    题解:by Mercury_Lc 阎小罗的矩阵给的n和m都不超过300,枚举一下所有情况就可以了,用前缀和来储存.数组a[x][y]代表前x行前y列的和是多少,那么枚举每一种切割的方式就可以.注意一下 ...

  8. ACM竞赛高手比其他程序员水平高很多吗?

    1. ACM是一种很直接的评价程序员水平的体系 2. ACM竞赛会带来很多机遇(深造or工作),同时又是一个不小的挑战 3. 为竞赛而竞赛的事情不可取 详细点击这里

  9. 第八届山东省ACM大学生程序设计竞赛个人总结

    因为省赛,从开学紧张到5月7号.心思也几乎全放在ACM的训练上.因为我还是校台球协会的会长,所以台协还有一些事情需要忙,但是我都给延迟了.老会长一直在催我办校赛,但我一直说 等等吧,因为校赛只能在周六 ...

随机推荐

  1. RabbitMQ九:远程过程调用RPC

    定义 RPC(Remote Procedure Call Protocol)——远程过程调用协议:它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议.RPC协议假定某些传输协议 ...

  2. 简要记录下localStorage在项目中的应用之一

    localStorage作为HTML5本地存储web storage特性的API之一,主要作用是将数据保存在客户端中.localStorage保存的数据,一般情况下是永久保存的,也就是说只要采用loc ...

  3. canvas基础绘制-倒计时(上)

    效果: html: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  4. (5)《Head First HTML与CSS》学习笔记---布局与定位

    层叠与CSS的权重判断 1.要理解层叠,除了前面的内容外还差最后一个知识点.你已经知道如何使用多个样式表来更好地组织你的样式,或者支持不同类型的设备.不过实际上用户访问你的页面时还有另外一些样式表. ...

  5. 关于对象.style currentstyle 的区别

    对象.style的方式只能获取行内写法的样式,但是外部引入的或者写在head里面的就无法获取,只能用currentstyle.

  6. saltstack 源码安装

    面向对象编程(oop) 面向对象: 面向对象三大特性: 封装 继承 多肽封装: 封装就是将具体的客观事物封装成抽象的类.并且类可以把自己的数据和方法只让可信的类或者对象操作,对不可行的进行信息隐藏继承 ...

  7. project .mpp 查看当天工作任务 1.选择自己 2.选择起始和终止时间 就显示当天的任务了

    project .mpp 查看当天工作任务 1.选择自己 2.选择起始和终止时间 就显示当天的任务了

  8. Vue.js系列之vue-router(上) (转载自向朔1992)

    概述 Vue非常适用于实践单页面应用程序也就是平时大家说的比较多的SPA(single page application),这点应该了解过Vue的应该都知道吧.一般的单页面应用是基于路由或页面之间的链 ...

  9. 查看cuda版本和cudann

    nvcc -V 没有找到直接查询cudann版本的命令,但发现cudann装在 /usr/local/cuda/lib64/目录下,libcudnn.so就是相应版本

  10. 【软件构造】第三章第三节 抽象数据型(ADT)

    第三章第三节 抽象数据型(ADT) 3-1节研究了“数据类型”及其特性 ; 3-2节研究了方法和操作的“规约”及其特性:在本节中,我们将数据和操作复合起来,构成ADT,学习ADT的核心特征,以及如何设 ...