'commit'
This commit is contained in:
39
C++专题课程/NOIP算法总结/字符串处理/笨小猴/P1125.cpp
Normal file
39
C++专题课程/NOIP算法总结/字符串处理/笨小猴/P1125.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include<iostream>
|
||||
#include<map>
|
||||
#include<math.h>
|
||||
#include<algorithm>
|
||||
#include<string.h>
|
||||
using namespace std;
|
||||
map<char,int>m;
|
||||
int main(){
|
||||
int maxx=-999999,minn=999999;
|
||||
char a[101];
|
||||
cin>>a;
|
||||
int l=strlen(a);
|
||||
for(int i=0;i<l;i++){
|
||||
m[a[i]]++;
|
||||
maxx=max(maxx,m[a[i]]);
|
||||
//minn=min(minn,m[a[i]]);
|
||||
}
|
||||
for(int i=0;i<l;i++){
|
||||
minn=min(minn,m[a[i]]);
|
||||
}
|
||||
//cout<<maxx<<' '<<minn<<endl;
|
||||
maxx-=minn;
|
||||
// cout<<maxx<<endl;
|
||||
if(maxx==0||maxx==1){
|
||||
cout<<"No Answer"<<endl;
|
||||
cout<<0;
|
||||
return 0;
|
||||
}
|
||||
for(int i=2;i<=sqrt(maxx);i++){
|
||||
if(maxx%i==0){
|
||||
cout<<"No Answer"<<endl;
|
||||
cout<<0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
cout<<"Lucky Word"<<endl;
|
||||
cout<<maxx;
|
||||
return 0;
|
||||
}
|
||||
1
C++专题课程/NOIP算法总结/字符串处理/笨小猴/试题链接.txt
Normal file
1
C++专题课程/NOIP算法总结/字符串处理/笨小猴/试题链接.txt
Normal file
@@ -0,0 +1 @@
|
||||
https://www.luogu.org/problemnew/solution/P1125
|
||||
Reference in New Issue
Block a user