int main(int argc, char const *argv[])
{
int t, n, i, count;
char curr;
long long int total;
scanf("%d", &t);
while(t--){
count = 0;
total = 0;
scanf("%d", &n);
for(i=0;i<n;i++){
scanf("%c", &curr);
if(curr == '1'){
++count;
}
}
if(count == 1){
printf("1\n");
}
else{
total = count + (count * (count-1))/2;
printf("%lld %d\n",total, count);
}
}
return 0;
}
When i enter the input in the following format,
1
4
1111
I'm expecting output as: 10 4
But what i get is : 6 3
.
The Program is logically & syntatically correct and i'm just unaware of what actually went wrong here. Help will be appreciated.