Rank of the Number
All submissions for this problem are available.
Read problems statements in Russian here
The Head Chef has received his id from the Association of Byteland . He wants to know the numerical rank of his number among the numbers that can be formed by the exact same digits ( i.e. among numbers having same number of 0's , 1's ... 9's as his id ) . Note that id's can start with 0 . Given a number, find the rank of the number .
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- Each test case contains a single integer N denoting the id the chef has received .
- For each test case, output a single line containing the answer to the given test case .
- 1 ≤ T ≤ 10000
- 1 ≤ number of digits in N ≤ 18
Input: 2 276 762 Output: 2 6
Example case 1.The numbers that can be formed with one '2' ; one '7' and one '6' in increasing order are :
The rank for 276 is 2 and rank for 762 is 6.
|Tags||bruteforce, cakewalk, cook40, enumeration, factorial, vineetpaliwal|
|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