6 条题解
-
2黎曜荣 (liyaorong) LV 6 @ 2023-11-15 20:29:01
#include<bits/stdc++.h> using namespace std; const int N=1e2+10; const int INF=0x3f3f3f3f;
string a; int num[30]; int maxx; int minn=100;
bool isPrime(int x){ if(x<2)return 0; if(x%20&&x!=2)return 0; for(int i=3;i*i<=x;i++) if(x%i0) return 0;
return 1;
} int main(){ cin>>a; int len=a.size(); for(int i;i<=len-1;i++){ num[a[i]-'a']++; } for(int i=0;i<=25;i++){ maxx=max(maxx,num[i]); if(num[i]) { minn=min(minn,num[i]); }
} if(isPrime(maxx-minn)){ cout<<"Lucky Word"<<endl<<maxx-minn; } else{ cout<<"No Answer"<<endl<<0; } return 0;
}
-
12023-11-15 20:29:20@
#include<bits/stdc++.h> using namespace std; string a; int num[30],maxx,minn = 100; bool isPrime(int n) { if(n < 2) return 0; if(n % 2 == 0 && n != 2) return 0; for(int i = 3;i * i <= n;i++) { if(n % i == 0) return 0; } return 1; } int main() { cin >> a; int len = a.size(); for(int i = 0;i <= len - 1;i++) num[a[i] - 'a']++; for(int i = 0;i <= 25;i++) { maxx = max(maxx,num[i]);
if(num[i]) minn = min(minn,num[i]); } if(isPrime(maxx - minn)) { cout << "Lucky Word" << endl << maxx - minn; } else { cout << "No Answer" << endl << 0; } return 0;
}
-
12023-4-21 21:13:36@
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std; bool prime(int n){ if(n==0||n==1){ return false; } if(n==2){ return true; } for(int i=3;i<sqrt(n);i++){ if(n%i==0){ return false; } } return true; } int main(){ char s[1000]; cin>>s; int a[24]={0},maxn=-999,minn=999; for(int i=0;i<strlen(s);i++){ a[s[i]-'a']++; } for(int i=0;i<24;i++){ if(a[i]>maxn){ maxn=a[i]; } if(a[i]<minn&&a[i]!=0){ minn=a[i]; } } int p=maxn-minn; if(prime(p)){ cout<<"Lucky Word"<<endl; cout<<p; }else{ cout<<"No Answer"<<endl; cout<<0; } return 0; }
-
02023-12-16 19:15:10@
-
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> const int INF=0x3f3f3f3f; const int N=1e5+10; using namespace std; string s; int a[30]; int maxx,minn=INF; bool zhangzhengbiaomeishili(int x) { if(x<2) return 0; for(int i=2;i*i<=x;i++) { if(x % i ==0) { return 0; } } return 1; } int main(){ cin>>s; int len =s.size(); for(int i=0;i<=len;i++) { a[s[i]-'a']++; } for(int i=0;i<26;i++) { maxx = max(maxx,a[i]); if(a[i]) minn=min(minn,a[i]); } if(zhangzhengbiaomeishili(maxx-minn)) cout<<"Lucky Word"<<endl<<maxx-minn; else { cout<<"No Answer"<<endl<<0; }
return 0; }
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> const int INF=0x3f3f3f3f; const int N=1e5+10; using namespace std; string s; int a[30]; int maxx,minn=INF; bool zhangzhengbiaomeishili(int x) { if(x<2) return 0; for(int i=2;i*i<=x;i++) { if(x % i ==0) { return 0; } } return 1; } int main(){ cin>>s; int len =s.size(); for(int i=0;i<=len;i++) { a[s[i]-'a']++; } for(int i=0;i<26;i++) { maxx = max(maxx,a[i]); if(a[i]) minn=min(minn,a[i]); } if(zhangzhengbiaomeishili(maxx-minn)) cout<<"Lucky Word"<<endl<<maxx-minn; else { cout<<"No Answer"<<endl<<0; }
return 0;
}
-
-
02023-11-15 20:20:24@
#include <iostream>
#include <cstdio> #include <cmath> #include <cstring> using namespace std; bool prime(int n){ if(n0||n1){ return false; } if(n2){ return true; } for(int i=3;i<sqrt(n);i++){ if(n%i0){ return false; } } return true; } int main(){ char s[1000]; cin>>s; int a[24]={0},maxn=-999,minn=999; for(int i=0;i<strlen(s);i++){ a[s[i]-'a']++; } for(int i=0;i<24;i++){ if(a[i]>maxn){ maxn=a[i]; } if(a[i]<minn&&a[i]!=0){ minn=a[i]; } } int p=maxn-minn; if(prime(p)){ cout<<"Lucky Word"<<endl; cout<<p; }else{ cout<<"No Answer"<<endl; cout<<0; } return 0; }
-
02022-11-25 14:39:12@
#include<bits/stdc++.h>
using namespace std;
bool check(int m){
for(int i=2;i*i<m;i++){ if(m%i==0){ return false; } } return true;
}
int main(){
char a[101]; int len,i,b[101]={0},maxx=INT_MIN,minn=INT_MAX; cin.getline(a,100); len=strlen(a); for(i=0;i<len;i++){ b[int(a[i])-96]++; } for(i=1;i<=26;i++){ if(b[i]!=0){ maxx=max(maxx,b[i]); minn=min(minn,b[i]); } } if(maxx-minn<2){ cout<<"No Answer"<<endl<<"0"; return 0; } if(check(maxx-minn)){ cout<<"Lucky Word"<<endl<<maxx-minn; return 0; } else{ cout<<"No Answer"<<endl<<"0"; return 0; } return 0;
}
- 1
信息
- ID
- 701
- 时间
- 1000ms
- 内存
- 50MiB
- 难度
- 7
- 标签
- 递交数
- 519
- 已通过
- 134
- 上传者