记录编号 |
307033 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2008]笨小猴 |
最终得分 |
100 |
用户昵称 |
Fmuckss |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.020 s |
提交时间 |
2016-09-13 16:51:55 |
内存使用 |
0.28 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
inline bool is_prime(int tar) {
if(tar == 1 or tar == 0) return false;
for (int i = 2; i * i <= tar; i++) {
if (tar % i) continue;
return false;
}
return true;
}
int cnt[30];
#define is_ch(x) (x <= 'z' and x >= 'a')
inline void read() {
char tmp = getchar();
while (not is_ch(tmp)) tmp = getchar();
while ( is_ch(tmp)) {
cnt[tmp - 'a' + 1]++;
tmp = getchar();
}
}
inline void solve() {
int mx_num = 0, mi_num = 100;
for (int i = 1; i <= 26; i++) {
if (not cnt[i]) continue;
if (mx_num < cnt[i]) mx_num = cnt[i];
if (mi_num > cnt[i]) mi_num = cnt[i];
}
if (is_prime(mx_num - mi_num)) printf("Lucky Word\n%d\n", mx_num - mi_num);
else printf("No Answer\n0\n");
}
int main() {
freopen("word.in", "r", stdin);
freopen("word.out", "w", stdout);
read();
solve();
return 0;
}