All submissions for this problem are available.
Chef is the owner of the loveliest restaurant in ChefTown. To make his work easier, all dishes are numbered by distinct positive integers, and you can order with this positive integer in Chef’s restaurant. Amazingly Chef has many kinds of recipes, so every positive integer denotes exactly one dish. To taste dish numbered with some integer C, you have to pay exactly C dollars.
Unfortunately not all the dishes are delicious. After years of working in his restaurant, Chef discovered that a dish is considered to be delicious if the number that denotes this dish consists of different digits. Let’s call such numbers “delicious numbers”. For example numbers 123, 1, 91, 102 are delicious but 122, 11, 900 are not.
Ira is a little girl from the University of Lublin and she’s fond of traveling. Tonight she stops in ChefTown and wants to have a meal at Chef’s restaurant. On the one hand she has R dollars in her pocket and she is ready to spend it, on the other hand she wants to seem rich, so she won’t spend less than L dollars. Of course, since she is a little girl, she wants to order just one dish. It is difficult to make a choice for Ira because of variety of dishes.Now she asks you to find out the number of delicious dishes Ira may order, considering her conditions.
First line contains single integer T (1 ≤ T ≤ 200000) – the number of test cases. Each test case consists of two positive integers in a line - L and R (1 ≤ L ≤ R ≤ 1018).
For every test case, output the answer on a separate line.
Input: 2 5 13 1 100 Output: 8 90
For the first test Ira can order every dish from 5 to 13 except 11.
|Tags||Rubanenko, bruteforce, nov12, simple, simple-math|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.