From dd684349c67c988ef19707cb65e637b6906fac75 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Fri, 8 Jul 2022 19:54:42 +0200 Subject: Solved some new problems --- codechef/CountSubstrings/inp | 0 codechef/CountSubstrings/main | Bin 0 -> 24688 bytes codechef/CountSubstrings/main.cpp | 18 ++++++++++++++++++ codechef/CountSubstrings/main_input0.txt | 5 +++++ codechef/CountSubstrings/main_output0.txt | 2 ++ 5 files changed, 25 insertions(+) create mode 100644 codechef/CountSubstrings/inp create mode 100755 codechef/CountSubstrings/main create mode 100644 codechef/CountSubstrings/main.cpp create mode 100644 codechef/CountSubstrings/main_input0.txt create mode 100644 codechef/CountSubstrings/main_output0.txt (limited to 'codechef/CountSubstrings') diff --git a/codechef/CountSubstrings/inp b/codechef/CountSubstrings/inp new file mode 100644 index 0000000..e69de29 diff --git a/codechef/CountSubstrings/main b/codechef/CountSubstrings/main new file mode 100755 index 0000000..16c37e0 Binary files /dev/null and b/codechef/CountSubstrings/main differ diff --git a/codechef/CountSubstrings/main.cpp b/codechef/CountSubstrings/main.cpp new file mode 100644 index 0000000..8ee40d2 --- /dev/null +++ b/codechef/CountSubstrings/main.cpp @@ -0,0 +1,18 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + string s; + cin >> s; + long long x = count(s.begin(), s.end(), '1'); + cout << (x * (x+1)) /2 << endl; + } +} diff --git a/codechef/CountSubstrings/main_input0.txt b/codechef/CountSubstrings/main_input0.txt new file mode 100644 index 0000000..dcf608b --- /dev/null +++ b/codechef/CountSubstrings/main_input0.txt @@ -0,0 +1,5 @@ +2 +4 +1111 +5 +10001 diff --git a/codechef/CountSubstrings/main_output0.txt b/codechef/CountSubstrings/main_output0.txt new file mode 100644 index 0000000..24350e0 --- /dev/null +++ b/codechef/CountSubstrings/main_output0.txt @@ -0,0 +1,2 @@ +10 +3 -- cgit v1.2.3