当前位置:网站首页>[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;
}
边栏推荐
- Project manager, can you draw prototypes? Does the project manager need to do product design?
- Jd.com 2: how to prevent oversold in the deduction process of commodity inventory?
- Quick sort
- web工程导入了mysql驱动jar包却无法加载到驱动的问题
- [FreeRTOS interrupt experiment]
- Redis has four methods for checking big keys, which are necessary for optimization
- word封面下划线
- Dynamic programming (tree DP)
- Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
- Sentinel sliding window traffic statistics
猜你喜欢
麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
Use sentinel to interface locally
行业专网对比公网,优势在哪儿?能满足什么特定要求?
程序员在互联网行业的地位 | 每日趣闻
Etcd database source code analysis -- etcdserver bootstrap initialization storage
ISP learning (2)
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
View workflow
The value of two date types is subtracted and converted to seconds
随机推荐
C'est un petit résumé de l'étude.
Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022
我想问一下 按照现在mysql-cdc的设计,全量阶段,如果某一个chunk的binlog回填阶段,
Platformio create libopencm3 + FreeRTOS project
Flink kakfa data read and write to Hudi
Quatre méthodes de redis pour dépanner les grandes clés sont nécessaires pour optimiser
MySQL reported an error datetime (0) null
The implementation of the maize negotiable digital warehouse receipt standard will speed up the asset digitization process of the industry
newton interpolation
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
ISP学习(2)
Flody的应用
CADD course learning (8) -- virtual screening of Compound Library
win10电脑系统里的视频不显示缩略图
yolov5 tensorrt加速
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Redis 排查大 key 的4種方法,優化必備
Use sentinel to interface locally
【Try to Hack】john哈希破解工具