# Chapter 7 Mathematics 10 AcWing 1646. Google's Recruitment

2022-11-24 23:10:08T_Y_F666

# 第七章 数学10 AcWing 1646. 谷歌的招聘

## 原题链接

AcWing 1646. 谷歌的招聘

## 思路

Natural number judgment test division prime

1 1 N N The prime number N / l n N N/lnN

#### 时间复杂度

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define ump unordered_map
#define ums unordered_set
#define pq priority_queue
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
typedef pair<int, int> PII;
const int N=10005, M=40000, INF=0x3f3f3f3f3f3f3f3f;
const double Exp=1e-8;
//int t, n, m, cnt, ans;
int n, k, pri[M], cnt=0;
bool st[M];
char c[1005];
string s;
inline int rd(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
void isp(){
rep(i, 2, M){
if(!st[i]){
pri[cnt++]=i;
for(int j=i*2; j<=M; j+=i){
st[j]=true;
}
}
}
}
bool is(int xx){
for(int i=0; pri[i]<=xx/pri[i]; ++i){
if(!(xx%pri[i])){
return false;
}
}
return true;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
isp();
n=rd(), k=rd();
scanf("%s", c);
s=c;
bool flag=false;
rep(i, 0, s.size()-k+1){
if(is(stoi(s.substr(i, k)))){
flag=true;
printf("%s\n", (s.substr(i, k)).c_str());
break;
}
}
if(!flag){
puts("404");
}
return 0;
}


## 参考文献

AcWing 1646. 谷歌的招聘（PAT甲级辅导课）y总视频讲解