#P8022. [ONTAK2015] Cięcie

[ONTAK2015] Cięcie

Problem Description

Given a digit string NN of length kk and three prime numbers p,q,rp, q, r, split NN into three non-empty substrings such that the first substring is divisible by pp, the second substring is divisible by qq, and the third substring is divisible by rr, and none of the three substrings has a leading 00.

Note: A single digit 00 is allowed.

Input Format

The first line contains four integers k,p,q,rk, p, q, r.

The second line contains a digit string NN of length kk.

Output Format

Output one integer, the total number of valid splitting ways.

19 2017 2027 2029
2017202741127832029
2

Hint

For 100%100\% of the testdata, 1k1061 \leq k \leq 10^6, 2015<p,q,r1052015 < p, q, r \leq 10^5, and p,q,rp, q, r are prime numbers.

Translated by ChatGPT 5