zl程序教程

您现在的位置是:首页 >  其他

当前栏目

【PAT乙级】1094 谷歌的招聘 (20 分)

谷歌 20 招聘 PAT 乙级
2023-09-11 14:15:52 时间

在这里插入图片描述
题目地址

#include<bits/stdc++.h>
using namespace std;
int n,k; 
string s;
bool check(string s)
{
	long long int a=stol(s);
    if(a<=1) return false; //会卡测试点2
	for(long long int i=2;i<=a/i;i++) if(a%i==0) return false;
    cout<<s;
	return true;
}
int main(void)
{
	cin>>n>>k;
	cin>>s;
	for(int i=0;i<=n-k;i++)
	{
		string temp=s.substr(i,k);
		if(check(temp)) return 0;
	}
	cout<<"404"; 
	return 0;
}