?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
140285566 |
Practice: 20h51a0434 |
1609C - 48 | C++17 (GCC 7-32) | Accepted | 748 ms | 780 KB | 2021-12-22 20:05:16 | 2021-12-22 20:05:16 |
#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; }
?
?
?
?