我胡汉三又回来了
NOIP2020 钱都交完了才发现理论知识不过关而且准备时间不足一个月的我.jpg
二叉树?链表?救命
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include<iostream> using namespace std; int main(){ string word; cin>>word;
int charnum[26]={0}; for(int i=0;i<word.length();i++){ int charr=word[i]-'a'+1; charnum[charr]++; }
int maxx=0,minn=100; for(int i=0;i<26;i++){ if(charnum[i]>maxx) maxx=charnum[i]; if(charnum[i]>0&&charnum[i]<minn) minn=charnum[i]; }
int monkey=maxx-minn,zhishu=0; for(int i=2;i<=monkey;i++){ if(monkey%i==0) zhishu++; } if(zhishu==1){ cout<<"Lucky Word"<<endl<<monkey<<endl; }else cout<<"No Answer"<<endl<<"0"<<endl; return 0; }
|