Created
July 26, 2017 14:01
-
-
Save lazyakshay/f35f9eea870ef2639d13d8a48ace7fe8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int prime[] = {67,71,73,79,83,89,97,101,103,107,109,113}; | |
int t; | |
cin>>t; | |
while(t--){ | |
int n; | |
cin>>n; | |
string s; | |
cin>>s; | |
int len = s.length(); | |
for(int i=0;i<len;i++){ | |
int j=0; | |
while(int(s[i])>=prime[j]) j++; | |
if(int(s[i])<= 67) cout<<char(67); | |
else if(int(s[i])>=113) cout<<char(113); | |
else { | |
int a = int(s[i]) - prime[j-1]; | |
int b = prime[j] - int(s[i]); | |
if(a<=b) cout<<char(prime[j-1]); | |
else cout<<char(prime[j]); | |
} | |
} | |
cout<<"\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment