1 solutions
-
0
C++ :
#include<iostream> #include<cstring> #include<algorithm> #include<cmath> bool zhishu(int); using namespace std; bool zhishu(int d) { int x=2; while(x<=sqrt(d)&&d%x!=0) x++; if(x>sqrt(d)) return 1; else return 0; } int main() { string s; cin>>s; int a[100]; int w=-1; int L=s.size(),ans=0; for(int i=0;i<=L-1;i++) { w++; for(int j=0;j<=L-1;j++) if(s[i]==s[j]) ans++; a[w]=ans; ans=0; } sort(a+0,a+w+1,less<int>()); if(a[w]==a[0]||a[w]-a[0]==1) { cout<<"No Answer"<<endl<<0; return 0; } if(zhishu(a[w]-a[0])==1) { cout<<"Lucky Word"<<endl<<a[w]-a[0]; return 0; } else { cout<<"No Answer"<<endl<<'0'; return 0; } }
- 1
Information
- ID
- 17920
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By