当前位置:网站首页>[noip2008 improvement group] stupid monkey
[noip2008 improvement group] stupid monkey
2022-07-06 04:47:00 【Recurss】
Title Description
Stupid little monkey has a small vocabulary , So every time I do multiple choice questions, I have a headache . But he found a way , It has been proved that , It's a very good way to choose the right option !
The specific description of this method is as follows : hypothesis maxn
It's the number of letters that appear most frequently in a word ,minn
It's the number of letters that appear the least in a word , If maxn-minn
It's a prime number , So stupid little monkey thinks it's a Lucky Word
, Such a word is probably the right answer .
Input format
A word , Only lowercase letters are possible , And the length is less than 100 100 100.
Output format
There are two lines , The first line is a string , Suppose the input word is Lucky Word
, Then output “Lucky Word
”, Otherwise output “No Answer
”;
The second line is an integer , If the input word is Lucky Word
, Output maxn-minn
Value , Otherwise output 0 0 0.
Examples #1
The sample input #1
error
Sample output #1
Lucky Word
2
Examples #2
The sample input #2
olympic
Sample output #2
No Answer
0
Tips
【 I/o sample 1 explain 】
word error
The letters that appear most in r r r There is 3 3 3 Time , The letter with the least number of occurrences appeared 1 1 1 Time , 3 − 1 = 2 3-1=2 3−1=2, 2 2 2 Prime number .
【 I/o sample 2 explain 】
word olympic
The letters that appear most in i i i There is 1 1 1 Time , The letter with the least number of occurrences appeared 1 1 1 Time , 1 − 1 = 0 1-1=0 1−1=0, 0 0 0 Not prime .
( The original problem has been corrected )
noip2008 Improve the first question
/* * @Description: To iterate is human, to recurse divine. * @Autor: Recursion * @Date: 2022-07-03 23:24:38 * @LastEditTime: 2022-07-03 23:46:08 */
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;
const int N = 1e6;
bool sushu(int x)
{
if(x==0||x==1) return false;
if(x==2) return true;
for(int j=2;j*j<=x;j++)
{
if(x%j==0) return false;
}
return true;
}
int maxn,minn = INF;
string s;
int arr[N];
int sum[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
for(int i = 0;i < s.length();i ++){
sum[s[i] - 'a']++;// Find the number of occurrences of each letter
}
// Find the maximum and minimum
for(int i=0;i<26;i++){
// Traverse 26 Letters
if(sum[i]>maxn) maxn=sum[i];// Compare maxn
if(sum[i]>0&&sum[i]<minn) minn=sum[i];// Compare minn, Only compare the letters that appear
}
int ans = maxn - minn;
if(sushu(ans))
cout << "Lucky Word" << endl << ans;
else
cout << "No Answer" << endl << 0;
return 0;
}
边栏推荐
- 饼干(考试版)
- Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
- Easyrecovery reliable and toll free data recovery computer software
- 项目经理,你会画原型嘛?项目经理需要做产品设计了?
- 我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
- Ue5 small knowledge points to enable the setting of lumen
- Weng Kai C language third week 3.1 punch in
- Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
- Yyds dry inventory automatic lighting system based on CC2530 (ZigBee)
- [mathematical modeling] differential equation -- sustainable development of fishing industry
猜你喜欢
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
Codeforces Round #804 (Div. 2)
Zynq learning notes (3) - partial reconfiguration
Digital children < daily question> (Digital DP)
几种RS485隔离通讯的方案介绍
ORM aggregate query and native database operation
Etcd database source code analysis -- etcdserver bootstrap initialization storage
Visio draws Tai Chi
Case of Jiecode empowerment: professional training, technical support, and multiple measures to promote graduates to build smart campus completion system
SQL injection vulnerability (MSSQL injection)
随机推荐
2021robocom robot developer competition (Preliminary)
Introduction of several RS485 isolated communication schemes
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
2021 RoboCom 世界机器人开发者大赛-本科组(复赛)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Microservice resource address
How to realize automatic playback of H5 video
Leetcode 186 Flip the word II in the string (2022.07.05)
Fuzzy -- basic application method of AFL
Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
Excellent PM must experience these three levels of transformation!
关于imx8mp的es8316的芯片调试
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
[buuctf.reverse] 159_[watevrCTF 2019]Watshell
After learning classes and objects, I wrote a date class
图论的扩展
Postman前置脚本-全局变量和环境变量
MySQL reported an error datetime (0) null