본문 바로가기

problem solving/Problem Solving

Barbara Bennett's Wild Numbers


http://acm.pku.edu.cn/JudgeOnline/problem?id=3340

Description

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.

Input

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 #.

Output

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).

Source

Tehran 2006


Solving

wild number란 숫자중에 ?를 포함한 숫자이다. 하나의 wild number a와 완전한 숫자 b가 주어졌을 때 a > b인 숫자는 몇개가 존재하는가?

'problem solving > Problem Solving' 카테고리의 다른 글

Kadj Squares  (0) 2008.10.16
Party at Hali-Bula  (0) 2008.10.12
Cake Cutting  (0) 2008.10.10
Triangle  (0) 2008.10.09
Square  (0) 2008.10.07