5 solutions

  • 2
    @ 2024-7-30 14:05:59
    #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;
    	}
    	for(int i=2;i<=t/i;i++)
    	{
    		if(t%i==0)
    		{
    			st=false;
    		}
    	}
    	if(st)
    	{
    		cout<<"Lucky Word"<<endl;
    		cout<<maxv-minv<<endl;
    	}else{
    		cout<<"No Answer"<<endl;
    		cout<<0<<endl;
    	}
    	return 0;
    }
    
  • 1
    @ 2026-4-1 11:36:03

    季总发的题解有语法错误,大家看我的

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string s;
        cin>>s;
        int n=s.size();
        int max=1,min=1000,x=0,q=n;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(i==j)
                {
                    continue;
                }
                if(s[i]==s[j]) x++;
                //if(s[i]==s[j]) q--;
            }
            if(x>=max)
            {
                max=x;
            }
            if(x<=min)
            {
                min=x;
            }
            q=n;
            x=0;
        }
        int y=max-min;
        int t=0;
        for(int i=1;i<=y;i++)
        {
            if(y%i==0)
            {
                t++;
            }
        }
        if(t==2)
        {
            cout<<"Lucky Word"<<endl;
            cout<<y;
            return 0;
        }
        else if(t!=2)
        {
            cout<<"No Answer"<<endl;
            cout<<"0";
        }
        return 0;
    }
    
    • 0
      @ 2026-4-12 10:48:17
      #include<bits/stdc++.h>
      using namespace std;
      int cnt[300];
      int main()
      {
      	string s;
      	cin>>s;
      	int minv=110,maxv=0;
      	for(char c:s)
      	{
      		cnt[c]++;
      	}
      	for(char c:s)
      	{
      		minv=min(minv,cnt[c]);
      		maxv=max(maxv,cnt[c]);
      	}
      	int t=maxv-minv;
      	bool st=1;
      	if(t<2) st=0;
      	for(int i=2;i<t;i++)
      	{
      		if(t%i==0)
      		{
      			st=0;
      		}
      	}
      	if(st)
      	{
      		cout<<"Lucky Word"<<endl<<t;
      	}
      	else
      	{
      		cout<<"No Answer"<<endl<<0;
      	}
      	return 0;
      }
      
      
      • 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;
        }
        
        
        • 0
          @ 2024-9-18 19:17:18
          #include<bits/stdc++.h>
          using namespace std;
          const int N=26;
          int geshu[N];
          int main()
          {
          	string shuru;
          	cin>>shuru;
          	int maxn=0,minn=100;
          	for(int i=0;i<shuru.size();i++)geshu[shuru[i]-'a']++;
          	for(int i=0;i<N;i++)
          	{
          		if(geshu[i]>maxn)maxn=geshu[i];
          		if(geshu[i]<minn&&geshu[i]!=0)minn=geshu[i];
          	}
          	int zhishu=maxn-minn;
          	bool chu=true;
          	if(zhishu<2)chu=false;
          	for(int i=2;i<zhishu;i++)if(zhishu%i==0)chu=false;
          	if(chu==true)
          	{
          		cout<<"Lucky Word"<<endl<<zhishu;
          	}
          	else
          	{
          		cout<<"No Answer"<<endl<<0;
          	}
          	return 0;
          }
          
          
          
          • 1

          Information

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