General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
211853292 Practice:
Meliodas123
1609C - 48 C++20 (GCC 11-64) Accepted 763 ms 752 KB 2023-07-02 19:40:52 2023-07-02 19:40:52
→ 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