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 ...
随机推荐
- Webservice-初级实例(二)
去年这个时候在亿阳工作,经理让我做数据同步功能,用到WS,于是草草研究之后,就投入使用了.前两天同事给我讲解分配给我的项目时,讲到其中一块是数据同步功能,我不禁一笑,同事问笑什么,我说世界真是奇妙,去 ...
- POJ 1276 Cash Machine(多重背包)
Cash Machine Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24132 Accepted: 8446 Descrip ...
- 开源Office Word——DocX
1.前言 请阅读前请看以下这位大神的文章 http://www.cnblogs.com/asxinyu/archive/2013/02/22/2921861.html 另附两个附件 1.DocX.DL ...
- KMP算法---字符串匹配
算法细节详见点击打开链接和点击打开链接 #include <stdio.h> #include <stdlib.h> #define N 7 #define M 15 void ...
- EXE文件结构和读取方法
一.EXE文件概念 EXE File英文全名executable file .译作可运行文件,可移植可运行 (PE) 文件格式的文件,它能够载入到内存中.并由操作系统载入程序运行,是可在操作系统存储空 ...
- JDK源码学习系列05----LinkedList
JDK源码学习系列05----LinkedList 1.LinkedList简介 LinkedList是基于双向链表实 ...
- Android从无知到有知——NO.7
的ip拨号器在监听外拨电话时用的是系统提供的广播事件.而有些时候我们须要自己设定广播事件来满足特定的须要. Ok,今天整一下自己定义广播事件,我们用一个状态监測模块向一个3G模块发送报警信息来实现这一 ...
- 发布Ubuntu/Linux系统cache,增加可用内存空间
桌面Ubuntu总内存4G,但free只有内存有100M 重视top命令检查看到真正的能力free内存.以下是真正的内存使用情况的看法有一个命令. watch -n 1 cat /proc/memin ...
- Razor button
比起Web Form開發,在後端(.cs)寫法上大同小異,可選擇C#或VB.NET來撰寫:而在前端(.cshtml..vbhtml)則有比較大的差別,自 MVC3版本後,就以Razor為前端檢視引擎, ...
- easyui动力头 && 动态加入tabs
今天,在实现了业务时的,我们需要根据后台操作,以产生多个数据tab页,而且每一个tab页表格根据需要动态生成的标题数据. 返回后台数据格例如,下面的公式: 实现方法例如以下: //$("#c ...