please also give me the error dont just edit it
What is wrong in the code
#include<bits/stdc++.h> using namespace std; bool checkcb(string s){ //cout<<s<<endl; long long ll=stoll(s); int l[]={2,3,5,7,11,13,17,19,23,29}; if(ll==0 || ll==1) return false; for(auto i : l){ if(i==ll) return true; } for(auto i : l){ if((ll%i)==0){ return false; } } return true; } bool isvaid(int i,int j, bool *visited){ bool vis=false; for(int x=i; x<j; x++){ if(visited[x]!=false){ vis=true; //return false; }else{ visited[x]=true; } } if(vis) return false; return true; } int main() { int n; string s; cin>>n; cin>>s; int count=0; bool *visited=new bool[n]; for(int i=0 ;i<n; i++) visited[i]=false; for(int i=0; i<n; i++){ for(int j=1; j<=n-i; j++){ string str=s.substr(i,j); if(checkcb(str)){ //cout<<str<<endl; if(isvaid(i,j+i,visited)){ count++; } } }} cout<<count; return 0; }
check now =>
Try for test case:
11
44166181111
You will know your mistake.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.