1632. Barbara Bennett

单点时限: 2.0 sec

内存限制: 256 MB

A wild number is a string containing digits and question marks (like 36?1?8). A number X matches a wild number W if they have the same length, and every non-question mark character in X is equal to the character in the same position in W (it means that you can replace a question mark with any digit). For example, 365198 matches the wild number 36?1?8, but 360199, 361028, or 36128 does not. Write a program that reads a wild number W and a number X from input, both of length n, and determines the number of n-digit numbers that match W and are greater than X.

输入格式

There are multiple test cases in the input. Each test case consists of two lines of the same length. The first line contains a wild number W, and the second line contains an integer number X. The length of input lines is between 1 and 10 characters. The last line of input contains a single character #.

输出格式

For each test case, write a single line containing the number of n-digit numbers matching W and greater than X (n is the length of W and X).

样例

Input
36?1?8
236428
8?3
910
?
5
#
Output
100
0
4

5 人解决,8 人已尝试。

5 份提交通过,共有 11 份提交。

7.3 EMB 奖励。

创建: 16 年,8 月前.

修改: 6 年,8 月前.

最后提交: 2 年,9 月前.

来源: Tehran 2006

题目标签