测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A1093. [COCI-2006_2007-contest6]#6 V

编程题 省选/NOI-

题目描述

Zvonko is playing with digits again, even though his mother has warned him that he is doing too much math and should go outside to play with his friends.
In his latest game, Zvonko looks for multiples of an integer X, composed only of certain digits. A multiple of X is any number divisible by X.
In order to ruin Zvonko's fun, his mother decided to get a program that solves the problem. Write a program that calculates how many multiples of X are between A and B (inclusive), such that, when written in decimal, they contain only certain allowed digits.

输入格式

The first line of input contains three integers X, A and B (1 ≤ X < 1011, 1 ≤ A ≤ B < 1011).
The second line contains the allowed digits. The digits will be given with no spaces, sorted in increasing order and without duplicates.

输出格式

Output the number of multiples Zvonko can make on a single line.

输入输出样例

输入 #1
2 1 20 
0123456789
输出 #1
10
输入 #2
6 100 9294 
23689
输出 #2
111
输入 #3
5 4395 9999999999 
12346789
输出 #3
0 
上一题 去做题 下一题