Problem F

Statement
Copy Copied
F. Numbers and Stringstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFor each integer $$$x$$$ from $$$1$$$ to $$$n$$$, we will form the string $$$S(x)$$$ according to the following rules:  compute $$$(x+1)$$$;  write $$$x$$$ and $$$x+1$$$ next to each other in the decimal system without separators and leading zeros;  in the resulting string, sort all digits in non-decreasing order. For example, the string $$$S(139)$$$ is 011349 (before sorting the digits, it is 139140). The string $$$S(99)$$$ is 00199.Your task is to count the number of distinct strings among $$$S(1), S(2), \dots, S(n)$$$.InputThe first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.Each test case consists of one line containing a single integer $$$n$$$ ($$$1 \le n \le 10^{9} - 2$$$).OutputFor each test case, output a single integer — the number of distinct strings among $$$S(1), S(2), \dots, S(n)$$$.ExampleInput2421337Output42
948

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
4553 cpp 0 2026-02-23T10:42:33.39476Z View View View Retry
4552 cpp 1 2026-02-23T09:41:58.308725Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
786 20260222-064656 gemini gemini-3.1-pro-preview go false 2026-02-22T08:34:12.159583Z View View View View Retry