//求素数
1.从给定字符串截取m位长的
2.stoi转int型
3.判断是否为素数
//素数打表法 一个答案有段错误 ,是因为数据会大于1000000,对于大于N的直接计算也可通过
//还有就是最后输出 输出为字符串格式 按转为的整型输出会有答案错误,是0的问题
#include<bits/stdc++.h>
using namespace std;
const int N = 1000000;
bool prime[N];
bool isPrime(int a) {
if(a <=3) {
return true;
}
int end = sqrt(a);
for(int i=2; i<=end; i++) {
if(a%i == 0)
return false;
}
return true;
}
void setPrime() {
memset(prime, true, sizeof(prime));
int tmp = sqrt(N);
for(int i=3; i<=tmp; i+=2 ) {
if(prime[i])
for( int j=i+i; j<=N; j+=i ) prime[j]=false;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
// setPrime();
int n, m;
string s, tmp;
cin >> n >> m >> s;
for(int i=0; s[i+m-1]; i++) {
tmp = s.substr(i, m);
int a = stoi(tmp);
if(isPrime(a)) {
cout << tmp << endl;
return 0;
}
}
cout << 404 << endl;
return 0;
}