题目要求
P1125题目链接
建个数组,排下序,选择次数非0部分的 m a x − m i n max-min max−min值,最后判个质数。
0和1加个特判吧!
AC代码(Java语言描述)import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] count = new int[26];
Scanner scanner = new Scanner(System.in);
String word = scanner.nextLine();
scanner.close();
for (char c : word.toCharArray()) {
count[c-'a']++;
}
Arrays.sort(count);
int num = 0;
for (int i = 0; i
关注
打赏
热门博文
- 【Linux】Ubuntu20.04安装和卸载MySQL8
- 【Linux】Ubuntu 20.04 报错 curl: (23) Failure writing output to destination 的解决方法
- 【Java】JUnit 4.13.2 警告 ‘assertEquals(double, double)‘ is deprecated 的解决方法
- 【JavaScript】处理 @parcel/transformer-js: Browser scripts cannot have imports or exports.
- 【Node.js】Windows环境安装配置NVM和Node.js
- 【Python】处理TypeError: Plain typing.NoReturn is not valid as type argument
- 【Python】Matplotlib可视化50例
- 【C语言】C语言修改MySQL数据库
- 【Java】从默认包导入类和对象报错的解决方法
- 【Java】panel.getGraphics()报错空指针异常的解决方法