diff --git a/Luogu/P1125/P1125.cpp b/Luogu/P1125/P1125.cpp new file mode 100644 index 00000000..c192c5aa --- /dev/null +++ b/Luogu/P1125/P1125.cpp @@ -0,0 +1,38 @@ +#include + +using std::cin; +using std::cout; +using std::endl; + +int max, min; +std::string s; +std::map 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::min(); + min = std::numeric_limits::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; +}