这个需要注意的是相关的string转整数或者double的函数;
详见这个链接blog
#include <iostream>
#include <string>
using namespace std;
bool isPrime(int n) {if (n == 0 || n == 1) return false;for (int i = 2; i * i <= n; i++)if (n % i == 0) return false;return true;
}
int main() {int l, k;string s;cin >> l >> k >> s;for (int i = 0; i <= l - k; i++) {string t = s.substr(i, k);int num = stoi(t);if (isPrime(num)) {cout << t;return 0;}}cout << "404\n";return 0;
}