Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- bool arr[100001];
- int cases;
- void sieve(){
- arr[0] = true;
- arr[1] = true;
- for(int i=4;i<=100000;i+=2){
- arr[i] = true;
- }
- for(int i=3;i*i<=100000;i+=2){
- for(int j = i*i;j<=100000 ;j+=i){
- arr[j] = true;
- }
- }
- }
- void solve(){
- int n;
- string str;
- cin>>n>>str;
- int alpha[26]={0};
- for(int i=0;i<str.size();i++){
- alpha[str[i]-'A']++;
- }
- int co=0;
- for(int i=0; i<26;i++){
- if(!arr[alpha[i]]) co++;
- }
- printf("Case %d:\n",++cases);
- if(!co) printf("Love is painful !\n");
- else{
- for(int i=0; i<26;i++){
- if(!arr[alpha[i]]) printf("%c = %d\n",i+'A',alpha[i]);
- }
- }
- }
- int main(){
- sieve();
- int tc;
- cin>>tc;
- while(tc--){
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment