General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
157395671 Practice:
Dhruv_Singh_Jadon
1609C - 48 C++20 (GCC 11-64) Accepted 779 ms 1984 KB 2022-05-16 16:32:07 2022-05-16 16:32:07
→ Source
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
bool prost(int n){
	if(n==1) return false;
	for(int i=2;i*i<=n;i++)
		if(n%i==0) return false;
	return true;
}
int main(){
	int t; cin>>t;
	while(t--){
	int n,k; cin>>n>>k;
	int a[n];
	long long s=0;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		if(prost(a[i])){
			long long r=1,l=1;
			while(r*k+i<n&&a[r*k+i]==1) r++;
			while(i-l*k>=0&&a[i-l*k]==1) l++;
			l--;r--;
			s+=l+r+l*r;
		}
	}
	cout<<s<<endl;
	}
	return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details