error
Lucky Word 2
#include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <map> using namespace std; #define ll long long map<char, int>mp; int tot, pri[100000+8]; bool is[100000+8]; struct node { char s; int time; } r[100000+8]; bool cmp(node a, node b) { return a.time>b.time; } void E() { tot = 0; memset(is, 1, sizeof(is)); is[0] = is[1] = 0; for(int i = 2; i<100000; i++) { if(is[i]) { pri[++tot] = i; for(int j = i+i; j<100000; j += i) is[j] = 0; } } } char s[100000+8]; int main() { E(); while(cin>>s) { int len = strlen(s); for(int i = 0; i<len; i++) { if(!mp[s[i]])mp[s[i]] = 1; else mp[s[i]]++; } int miao = 0, sum; for(map<char, int>::iterator ii = mp.begin(); ii != mp.end(); ii++) { r[miao].s = ii->first; r[miao].time = ii->second; miao++; } sort(r, r+miao, cmp); sum = r[0].time-r[miao-1].time; if(is[sum]) printf("Lucky Word\n%d\n", sum); else printf("No Answer\n0\n"); } return 0; }
原文:https://www.cnblogs.com/RootVount/p/10986598.html