比赛 |
20161115 |
评测结果 |
AAAAAAAAAA |
题目名称 |
军队 |
最终得分 |
100 |
用户昵称 |
KZNS |
运行时间 |
0.379 s |
代码语言 |
C++ |
内存使用 |
2.10 MiB |
提交时间 |
2016-11-15 10:12:24 |
显示代码纯文本
//KZNS
#include <cstdio>
#include <algorithm>
using namespace std;
#define Nmax 100004
#define Smax 1000004
int N, K;
int ls[Nmax];
int mxs;
int pls[Nmax];
int pid;
bool pd[Nmax];
void PPAP() {
for (int i = 2; i <= mxs; i++) {
if (!pd[i])
pls[pid++] = i;
for (int j = 0; j < pid && pls[j] * i <= mxs; j++) {
pd[pls[j]*i] = true;
if (!(i % pls[j]))
break;
}
}
}
void init() {
scanf("%d %d", &N, &K);
for (int i = 0; i < N; i++) {
scanf("%d", ls+i);
mxs = max(mxs, ls[i]);
}
PPAP();
}
int ans = 0;
bool hv[Smax];
int bls[20];
int rls[20];
void rerere(int x, int *A) {
A[0] = 1;
for (int i = 0; pls[i] * pls[i] <= x; i++) {
if (!(x % pls[i])) {
A[A[0]++] = pls[i];
x /= pls[i];
while (!(x % pls[i]))
x /= pls[i];
}
}
if (x > 1)
A[A[0]++] = x;
}
void work() {
int l = 0;
int S = 0;
for (int i = 0; i < N; i++) {
rerere(ls[i], bls);
for (int j = 1; j < bls[0]; j++) {
while (hv[bls[j]]) {
rerere(ls[l], rls);
for (int k = 1; k < rls[0]; k++)
hv[rls[k]] = false;
S -= ls[l++];
}
hv[bls[j]] = true;
}
S += ls[i];
if (S >= K)
ans = max(ans, i - l + 1);
}
printf("%d\n", ans);
}
int main() {
freopen("tarmy.in", "r", stdin);
freopen("tarmy.out", "w", stdout);
init();
work();
return 0;
}
//UBWH