我是靠谱客的博主 傲娇白羊,最近开发中收集的这篇文章主要介绍Boy or Girl CodeForces - 236A 与 P1125 [NOIP2008 提高组] 笨小猴,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Boy or Girl CodeForces - 236A
Boy or Girl CodeForces - 236A
题目
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).

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

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[200];
scanf("%s",a);
int len;
int count1=0,count2=0;
len=strlen(a);
int i,j,k,sum=0;
int count3;
count3=len;
sort(a,a+len);
for(i=0;i<len;i=i+count2)
{
count2=0;
for(j=i;j<len;j++)
{
if(a[i]==a[j])
{
count2++;
}
}
if(count2>1)
count3=count3-count2+1;
}
if(count3%2==0)
cout<<"CHAT WITH HER!";
else
cout<<"IGNORE HIM!";
return 0;
}

P1125 [NOIP2008 提高组] 笨小猴
题目

P1125 [NOIP2008 提高组] 笨小猴

题目描述
笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼。但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大!

这种方法的具体描述如下:假设maxn是单词中出现次数最多的字母的出现次数,minn是单词中出现次数最少的字母的出现次数,如果maxn-minn是一个质数,那么笨小猴就认为这是个Lucky Word,这样的单词很可能就是正确的答案。

输入格式
一个单词,其中只可能出现小写字母,并且长度小于100100。

输出格式
共两行,第一行是一个字符串,假设输入的的单词是Lucky Word,那么输出“Lucky Word”,否则输出“No Answer”;

第二行是一个整数,如果输入单词是Lucky Word,输出maxn-minn的值,否则输出00。

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int f(int a)
{
int i;
if (a <= 1) return -1;
for (i = 2; i <= sqrt(a); i++)
{
if (a % i == 0)
return -1;
break;
}
return 1;
}
int main()
{
char a[200];
int count = 0;
int maxn = -1, minn = 9000;
scanf("%s", a);
int len = strlen(a);
sort(a, a + len);
for (int i = 0; i < len; i=i+count)
{
count = 0;
for (int j = i; j < len; j++)
{
if (a[i] == a[j])
count++;
else if (a[i] != a[j])
{
break;
}
}
maxn = max(maxn, count);
minn = min(minn, count);
}
int sum;
sum = maxn - minn;
if (f(sum) == 1)
{
printf("Lucky Wordn%d", sum);
}
else
{
printf("No Answern0");
}
return 0;
}

两道题都是查找相同不同字符,计数。

最后

以上就是傲娇白羊为你收集整理的Boy or Girl CodeForces - 236A 与 P1125 [NOIP2008 提高组] 笨小猴的全部内容,希望文章能够帮你解决Boy or Girl CodeForces - 236A 与 P1125 [NOIP2008 提高组] 笨小猴所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(72)

评论列表共有 0 条评论

立即
投稿
返回
顶部