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 ...
随机推荐
- 10gocm->session5->数据库管理实验
Oracle数据库管理实验 一 传输表空间 二 创建分区表和分区索引 三 FGA细粒度审计 四 监控索引使用情况 五 创建含特殊字段类型的表 六 Flashback闪回技术 一 传输表空间,将ocmd ...
- PHP 字符串正则替换函数preg_replace使用说明
1. preg_replace() $msg = preg_replace("/<style>.+<\/style>/is", "", ...
- Codeforces Round #198 (Div. 2) C. Tourist Problem (数学+dp)
C. Tourist Problem time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round#308
A题,看样例就知道要求什么, 水过去 #include <stdio.h> #include <string.h> #include <stdlib.h> #i ...
- linux grep命令详解(转)
简介 grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它 ...
- 鸟书shell 学习笔记(一) shell专注于概念和命令
变量 variableName=value 等号左右不能有空格 变量内容有空格须要用"或者'括起来,可是 v="hello $name" $保持原有功能,单引號则不行 ...
- sql server基本流程语句
- WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示
原文:WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示 为方便描述, 这里仅以正方形来做演示, 其他图形从略. 运行时效果图:XAML代码:// Transform.XAML< ...
- Swing中弹出对话框的几种方式(转)
http://www.cnblogs.com/mailingfeng/archive/2011/12/28/2304289.html 在swing中,基于业务的考量,会有对话框来限制用户的行为及对用户 ...
- CopyOnWriteArrayList源代码阅读器
java.util.concurrent在相应的并发集合的包中定义的通用集合类,为了有效地处理并发场景.间CopyOnWriteArrayList它是合适ArrayList.顾名思义CopyOnWri ...