Problem of the day
A substring can start with a zero. The given number may also contain leading zeroes.
βS'= β5203β
Here, four substrings are divisible by 5: β5β, β520β, β20β, β0β.
Hence the answer is 4.
First-line contains 'T', denoting the number of Test cases.
For each Test case:
The first line contains an integer βNβ denoting the string βSβ length.
The second line contains a string βSβ of size βNβ.
Return an integer denoting the total number of substrings whose integral value are divisible by 5.
You don't need to print anything. Just implement the given function.
1 <= 'T' <= 10
1 <= 'N' <= 10^5
'0' <= 'S[i]' <= '9'
Time Limit: 1 sec
2
5
35602
3
100
6
5
For test case 1:
βS'= β35602β
Here, six substrings are divisible by 5: β35β, β3560β, β5β, β560β, β60β, β0β.
Hence the answer is 6.
For test case 2:
βS'= β100β
Here, five substrings are divisible by 5: β10β, β100β, β0β, β00β, β0β.
Hence the answer is 5.
2
1
9
4
1555
0
9