My issue
please someone explain the problem statement simply
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
return 0;
}
Problem Link: BITPLAY Problem - CodeChef
please someone explain the problem statement simply
#include <iostream>
using namespace std;
int main() {
// your code goes here
return 0;
}
Problem Link: BITPLAY Problem - CodeChef
@freshman_01
The question asked that in how many ways u can make string o of length (n-1)/2 . such that it will satisfy the condition .
I have written a much simpler code for this problem , hope u will get the logic .
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
long long int ans=1;
for(int i=2;i<n;i+=2)
{
int d=s[i-1]-'0'+s[i-2]-'0';
if(s[i]=='0'&&d==0)
ans=(ans*3)%1000000007;
else if(s[i]=='0'&&d==1)
ans=(ans*1)%1000000007;
else if(s[i]=='0'&&d==2)
ans=(ans*1)%1000000007;
else if(s[i]=='1'&&d==0)
ans=0;
else if(s[i]=='1'&&d==1)
ans=(ans*2)%1000000007;
else if(s[i]=='1'&&d==2)
ans=(ans*2)%1000000007;
}
cout<<ans<<endl;
}
return 0;
}