ورود

View Full Version : مشکل در ترجمه ی سوال ACM



farzane-ms
سه شنبه 09 فروردین 1390, 00:59 صبح
سلام
من سوال زیر رو ترجمه کردم اما رابطه ی بین ورودی و خروجی ها رو متوجه نشدم، ممنون میشم کمکم کنید.
سوال برای سال 2006



Problem B. Barbara Bennett's Wild Numbers

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(filename: B.in)

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

Sample Input and Output




B.in

36?1?8
236428
8?3
910
?
5
#

Standard Output

100
0
4

dokhmal
سه شنبه 09 فروردین 1390, 01:33 صبح
نکته ای که باید توجه کنید اینه که عدد دوم حتما باید کوچیکتر از عدد اول باشه اول براتون ورودی آخر یعنی ؟ رو توضیح میدم :
نوشته ؟ و بعد 5 و جوابی که در خروجی داده 4 هست یعنی 4 عدد هستن که میتونن جایگزین ؟ بشن که کوچیکتر از 5 هستن
در مورد دومی که عدد دوم چون کوچیکتر هست خروجی 0 رو داریم
و در مورد سومی از عدد 236428 تا 891936 فقط 100 عدد هستن که که در این بازه عددی قرار دارند یعنی 10 * 10 :
801036
801136
801236
801336
801436
.
.
.
801936
این 10 تا عدد اول حالا برای 9 عدد باقی مانده هم که به همین ترتیب حساب کنیم جواب 100 می شود.

farzane-ms
سه شنبه 09 فروردین 1390, 02:34 صبح
ممنون، حل شد. :لبخندساده: