#SRD0000132. Những xâu con tuyệt vời (Awesome Substrings)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những xâu con tuyệt vời (Awesome Substrings)
Awesome Substrings
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a binary string , call a nonempty contiguous substring awesome if it contains at least one 1 and its length is divisible by the number of 1 characters in it. Count all awesome substrings. Equal substrings at different positions are counted separately.
Input
One line containing a binary string .
Output
Print the number of awesome substrings.
Subtasks
- Subtask 1 (10 points): .
- Subtask 2 (20 points): .
- Subtask 3 (30 points): .
- Subtask 4 (40 points): (full original limits).
Examples
Example 1
Input
111
Output
6
Explanation: Every substring consists entirely of 1s. There are substrings.
Example 2
Input
01010
Output
10
Explanation: There are two occurrences each of 1, 01, 10, and 010, plus 1010 and 0101.
Example 3
Input
0000
Output
0
Explanation: No substring contains any 1.
Example 4
Input
1111100000
Output
25
Explanation: Counting substrings whose length is a positive multiple of their number of 1s gives 25.