CodeChef::CSUB
#include <bits/stdc++.h> using namespace std ; #define boost ios :: sync_with_stdio ( 0 ); cin . tie ( 0 ) #define ll long long int main (){ boost ; ll t ; cin >> t ; while ( t --) { ll n ; cin >> n ; string seq ; cin >> seq ; ll count { 0 }; for ( int i = 0 ; i < seq . size (); i ++){ if ( seq [ i ] == '1' ) count ++ ; } cout << ( count *( count + 1 ))/ 2 << ' \n ' ; } return 0 ; }
Comments
Post a Comment