3 solutions

  • 0
    @ 2025-12-6 15:57:54
    #include<bits/stdc++.h>
    using namespace std;
    const int N=200;
    int st[N];
    int main()
    {
    	string str;
    	cin>>str;
    	int minv,maxv;
    	int len=str.size();
    	for(int i=0;i<len;i++)
    	{
    		st[str[i]]++;
    	}
    	for(int i=0;i<len;i++)
    	{
    		if(i==0||st[str[i]]>maxv)
    			maxv=st[str[i]];
    		if(i==0||st[str[i]]<minv)
    			minv=st[str[i]];
    	}
    	int t=maxv-minv;
    	bool st=true;
    	if(t<2)
    	{
    		st=false;
    	}
    	int cnt=0; 
    	for(int i=1;i<=n;i++)
    	{
    		if(t%i==0)
    		{
    			cnt++;
    		}
    	}
    	if(cnt!=2)
    	{
    		st=false;
    	}
    	if(st)
    	{
    		cout<<"Lucky Word"<<endl;
    		cout<<maxv-minv<<endl;
    	}else{
    		cout<<"No Answer"<<endl;
    		cout<<0<<endl;
    	}
    	return 0;
    }
    
    

    Information

    ID
    928
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    111
    Accepted
    24
    Uploaded By