一年前的代码
#include <bits/stdc++.h>
using namespace std;
const char maxn=105;
char a[maxn];
bool pdss(int u)
{
int q=0;
for(int j=1;j<=u;j++)
{
if(u%j==0)
{
q++;
}
}
if(q==2&&u!=1)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
int x=0,x2=0,y=101,c;
cin>>a;
int len=strlen(a);
sort(a,a+len-1);
for(int j=0;j<len;j++)
{
x++;
if(x>x2)
{
x2=x;
}
if(a[j+1]!=a[j])
{
if(x<y)
y=x;
x=0;
}
}
c=x2-y;
if(pdss(c)==1)
{
cout<<"Lucky Word"<<endl<<c;
}
else
{
cout<<"No Answer"<<endl<<0;
}
return 0;
}
hack:
abaa
正确答案:
Lucky Word
2
错误答案:
No Answer
0