General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
142132461 Practice:
gouthamb
1609C - 48 C++17 (GCC 7-32) Accepted 732 ms 780 KB 2022-01-10 06:23:41 2022-01-10 06:23:41
→ Source
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#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