当前位置:网站首页>All in one 1407: stupid monkey
All in one 1407: stupid monkey
2022-07-04 00:42:00 【Studying hard】
【 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 maxnmaxn It's the number of letters that appear most frequently in a word ,minnminn It's the number of letters that appear the least in a word , If maxn−minnmaxn−minn It's a prime number , So stupid little monkey thinks it's a Lucky WordLucky Word, Such a word is probably the right answer .
【 Input 】
There is only one line , It's a word , Only lowercase letters are possible , And the length is less than 100100.
【 Output 】
There are two lines , The first line is a string , Suppose the input word is Lucky WordLucky Word, Then output “Lucky WordLucky Word”, Otherwise output “No AnswerNo Answer”;
The second line is an integer , If the input word is Lucky WordLucky Word, Output maxn−minnmaxn−minn Value , Otherwise output 00.
【 sample input 】
error
【 sample output 】
Lucky Word 2
【 Tips 】
The sample input :
Examples #2:
olympic
Sample output :
Examples #2:
No Answer 0
#include<stdio.h> #include<string.h> int main() { char s[120]; scanf("%s", s); int len = strlen(s); int i; int a; int b[150] = { 0 }; for (i = 0; i < len; i++) { a = s[i]; b[a]++; } int max=0; int min=101; for (i = 0; i < 150; i++) { if (b[i] != 0) { if (max < b[i]) max = b[i]; if (min > b[i]) min = b[i]; } } int num = max - min; if (num < 2) { printf("No Answer\n"); printf("0"); } if (num >= 2) { for (i = 2; i <= num; i++) { if (num % i == 0) { break; } } if (num == i) { printf("Lucky Word\n"); printf("%d", num); } else { printf("No Answer\n"); printf("0"); } } return 0; }
边栏推荐
- Network layer - routing
- 老姜的特点
- Sequence list and linked list
- Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
- Why use get/set instead of exposing properties
- Delete all elements with a value of Y. The values of array elements and y are entered by the main function through the keyboard.
- [PHP basics] session basic knowledge, application case code and attack and defense
- 删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
- Wechat official account and synchronization assistant
- How to use AHAS to ensure the stability of Web services?
猜你喜欢
查询效率提升10倍!3种优化方案,帮你解决MySQL深分页问题
ESP Arduino playing with peripherals (V) basic concept of interrupt and timer interrupt
Axure resources and prototype tool Axure RP 9 download
What is the GPM scheduler for go?
Entropy and full connection layer
CesiumJS 2022^ 源码解读[8] - 资源封装与多线程
MySQL is installed as a Windows Service
STM32 key light
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
Mobile asynchronous sending SMS verification code solution -efficiency+redis
随机推荐
Swagger2 quick start and use
[common error] UART cannot receive data error
Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
不得不会的Oracle数据库知识点(二)
ISBN number
Struct in linked list
Similarities and differences of text similarity between Jaccard and cosine
What is the GPM scheduler for go?
Eight year test old bird, some suggestions for 1-3 year programmers
system. Exit (0) and system exit(1)
On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
2-redis architecture design to use scenarios - four deployment and operation modes (Part 2)
How to set the response description information when the response parameter in swagger is Boolean or integer
The culprit of unrestrained consumption -- Summary
不得不会的Oracle数据库知识点(三)
【.NET+MQTT】.NET6 环境下实现MQTT通信,以及服务端、客户端的双边消息订阅与发布的代码演示
NLP pre training technology development
What are the application fields of digital twins in industry?