Untitled
unknown
plain_text
a year ago
1.5 kB
10
Indexable
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
template<class T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
void File() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("errors.txt", "w", stderr);
#else
#endif
}
int main() {
File();
const int N = 1e7 + 16, MOD = 1e9 + 7;
vector<bool> is_prime;
is_prime.assign(N, true);
is_prime[0] = is_prime[1] = false;
for (long long i = 2; i < N; ++i)
if (is_prime[i])
for (long long j = i * i; j < N; j += i)
is_prime[j] = false;
int n, m;
cin >> n >> m;
vector<int> a(n);
for(auto &x: a)
cin >> x;
ll l = 0, ans = 1;
while(l < n) {
int cnt = 0;
while (l < n && cnt < m) cnt += is_prime[a[l++]];
if (cnt < m) {
ans = (cnt > 0 ? 0 : ans);
break;
}
int sz = 1;
while (l < n && !is_prime[a[l]]) ++l, ++sz;
if (l < n)
ans = ans * sz % MOD;
}
cout << ans << "\n";
return 0;
}Editor is loading...
Leave a Comment