为啥70啊
查看原帖
为啥70啊
110705
caek楼主2020/8/7 20:38
#include <bits/stdc++.h>
using namespace std;
string a;
int b[100000],tot,ans,c[100000],pop;
int main()
{
   cin>>a;
   for (int i=0; i<a.size(); i++)
   {
      b[a[i]-'a']++;
      tot++;
   }
   for (int i=1; i<=1200; i++)
   {
      if (b[i]!=0)
         c[pop++]=b[i];
   }
   sort(c+1,c+a.size()+1);
   ans=c[tot]-c[0];
   if (ans<0)
      ans=c[0];
   if (ans==2)
   {
      cout<<"Lucky Word"<<endl;
      cout<<ans;
      return 0;
   }
   if (ans==0)
   {
         cout<<"No Answer"<<endl;
	     cout<<0;
	     return 0;
   }
   for (int i=2; i<=ans-1; i++)
   {
      if (ans%i==0)
      {
	     cout<<"No Answer"<<endl;
	     cout<<0;
	     return 0;
	  }
   }
   cout<<"Lucky Word"<<endl;
   cout<<ans;
   return 0;
} 

1 8 9WA了

2020/8/7 20:38
加载中...