提交时间:2022-05-21 19:59:59

运行 ID: 658

#include<bits/stdc++.h> using namespace std; int ton[200], x=1, y=1, z, k=0; int main(){ char a[200]; memset(a,0,sizeof(a)); cin>>a; for(int i=0;i<strlen(a);i++){ ton[a[i]]++; } for(int i=97;i<123;i++){ if(ton[i]<x&&ton[i]!=0){ x=ton[i]; } if(ton[i]>y){ y=ton[i]; } } z=y-x; //cout<<"z="<<z<<endl<<x<<" "<<y; for(int i=2;i<=z;i++){ if(z%i==0){ if(z==i){ k=1; } else k=0; } } if(k==1){ cout<<"Lucky Word"<<endl<<z; } else cout<<"No Answer"<<endl<<z; return 0; }