mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
P1125 [NOIP2008 提高组] 笨小猴
R63986007
This commit is contained in:
parent
0e1640ccee
commit
1d8ca13bfa
38
Luogu/P1125/P1125.cpp
Normal file
38
Luogu/P1125/P1125.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
int max, min;
|
||||
std::string s;
|
||||
std::map<char, int> map;
|
||||
|
||||
bool isPrime(int x) {
|
||||
if (x < 2) return false;
|
||||
for (int i = 2; i * i <= x; i++) {
|
||||
if (x % i == 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
max = std::numeric_limits<int>::min();
|
||||
min = std::numeric_limits<int>::max();
|
||||
cin >> s;
|
||||
for (char c : s) {
|
||||
map[c]++;
|
||||
}
|
||||
for (auto c : map) {
|
||||
max = std::max(max, c.second);
|
||||
min = std::min(min, c.second);
|
||||
}
|
||||
if (isPrime(max - min)) {
|
||||
cout << "Lucky Word" << endl
|
||||
<< max - min << endl;
|
||||
} else {
|
||||
cout << "No Answer" << endl
|
||||
<< 0 << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user