Getting wrong answer in the problem ( CSUB Problem - CodeChef ) . Can someone please tell me what I am doing wrong.
Here’s my code
#include
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
int t;
cin>>t;
while(t–)
{
int n;;
cin>>n;
char s[n];
int No_of_1s=0;
for(int i=0;i<n;i++)
{
cin>>s[i];
if(s[i]==‘1’)
{
No_of_1s++;
}
}
long long int No_of_substrings=0;
if(No_of_1s==0)
{
No_of_substrings=0;;
}
else
{
No_of_substrings=No_of_1s+No_of_1s*(No_of_1s-1)/2;
}
cout<<No_of_substrings<<"\n";
}// your code goes here
return 0;
}