codeforces 236A . Boy or Girl(串水问题)
1 second
256 megabytes
standard input
standard output
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.
The first line contains a non-empty string, that contains only lowercase English letters — the user name. This string contains at most 100 letters.
If it is a female by our hero's method, print "CHAT WITH HER!" (without the quotes), otherwise, print "IGNORE HIM!" (without the quotes).
wjmzbmr
CHAT WITH HER!
xiaodao
IGNORE HIM!
sevenkplus
CHAT WITH HER!
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!".
#include <iostream>
#include<memory.h>
#include<stdlib.h>
using namespace std;
int cmp(const void *a,const void *b)
{
return *(char *)a-*(char *)b;
}
int main()
{
char c[101];
int k,s,i,j;
while(cin>>c)
{
s=0;
k=strlen(c);
qsort(c,k,sizeof(c[0]),cmp);
for(i=0,j=1; i<k; i++)
{
if(c[i]!=c[j])
{
j++;
s++;
}
else
{
j++;
}
}
if(s%2==0)
{
cout<<"CHAT WITH HER!"<<endl;
}
else
cout<<"IGNORE HIM!"<<endl;
memset(c,'\0',sizeof(c));
}
return 0;
}
版权声明:本文博客原创文章,博客,未经同意,不得转载。
codeforces 236A . Boy or Girl(串水问题)的更多相关文章
- 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 236A,虽然很水,但有一个很简单的函数用起来方便
A. Boy or Girl time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Beta Round #37 A. Towers 水题
A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...
- Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs
A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路
A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- codeforces 712B B. Memory and Trident(水题)
题目链接: B. Memory and Trident time limit per test 2 seconds memory limit per test 256 megabytes input ...
- codeforces 712A A. Memory and Crow(水题)
题目链接: A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
随机推荐
- 工程PMO工作
算起来,这是第一次以项目PMO人员的身份參与项目.尽管非常可惜没有从头參与,也没有參与到项目结束.仅仅有短短的两个月,但对项目PMO也可略窥一斑.如今就当个流水账写一写吧. 进项目组的时候,是中 ...
- 一个简单的带缓存http代理
眼下1.0版模型非常easy.即对客户机发来的请求进行简单处理后,转发到server.转发之前先检查本地缓存.假设有.则直接回送给客户本地资源 程序流程大致例如以下图: 缓存是通过把文件保存到磁盘上, ...
- 【Java先进】Lock、通过使用线程池
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util ...
- Silverlight之 xaml布局
目标:在两周内完成一个界面的功能 第1阶段:完成xaml的布局 准备:视频4-14节 第2阶段: 完成环状图 柱状图 TreeView样式 准备: 矢量绘图 telerik 自定义控件 自定义控件 ...
- UBUNTU12.04下安装配置体验gnome3
年. ubuntu12.04默认采用unity界面,但是自己更加喜欢gnome3的操作方式. 安装gnome3: sudo apt-get install gnome-shell 其实安装成功后,注 ...
- [Windows Phone 8]如何解决Lumia手机无法进入系统或开启?
原文:[Windows Phone 8]如何解决Lumia手机无法进入系统或开启? 摘要 相信有的人一定有遇过手机在更新的时候,齿轮转不停,过了好几小时还是一样,这就代表系统出现问题了,如今Nokia ...
- C++面试宝典2011版
1.new.delete.malloc.free关系 delete会调用对象的析构函数,和new相应free仅仅会释放内存,new调用构造函数.malloc与free是C++/C语言的标准库函数,ne ...
- ExtJs迄今datefield控制设置默认值
假设extjs4 datefield日期控件设置默认值.为当天的前一月,和后一月 Ext.Date.MONTH 月 Ext.Date.YEAR 年 Ext.Date.DAY ...
- c# 获取某个对象的[公有属性]的名称,类型,值
/// <summary> /// 获取某个对象的[公有属性]的名称,类型,值 /// </summary> /// <typeparam name="T&qu ...
- 在C#环境中动态调用IronPython脚本(二)
一.Python数据类型与C#数据类型的对应 Python中数据类型中的简单类型,例如int,float,string可以对应到C#环境中的int32,double,string,这些对应比较直观,P ...