Even-dominant Numbers

시간 제한3초메모리 제한2048 MB

요약
각 질의에서 x와 floor(sqrt(x))의 짝수 자릿수가 홀수 자릿수보다 많은 x의 개수를 [l, r] 구간에서 센다.
난이도

보통10점 중 5점

유형
수학, 이분 탐색, 누적 합, 구현
정답자
아직 제출이 없습니다

문제

This is an interactive problem.

Let xx be an even-dominant number if the total number of even decimal digits of xx and ⌊x⌋\left\lfloor \sqrt{x} \right\rfloor (the decimal representation of the square root of xx, rounded down to the nearest integer) is greater than the total number of odd decimal digits of these numbers.

For example, 222,213222\\,213 is an even-dominant number because the total number of even digits in 222,213222\\,213 and ⌊222,213⌋=471\left\lfloor \sqrt{222\\,213} \right\rfloor = 471 is 55, which is greater than 44, the total number of odd digits. However, the number 22 is not an even-dominant number because the total number of even digits in 22 and ⌊2⌋=1\left \lfloor \sqrt{2} \right \rfloor = 1 is equal to the total number of odd digits.

Determine the number of even-dominant numbers in the segment \[ℓ,r]\[\ell, r].

입력

The first line contains one integer tt (1≤t≤10,0001 \leq t \leq 10\\, 000): the number of queries.

Each of the next tt lines contains two integers ℓ_i\ell\_i and r_ir\_i (1≤ℓ_i≤r_i≤10121 \leq \ell\_i \leq r\_i \leq 10^{12}) denoting the segment for the ii-th query.

출력

For each query, print a line with a single integer: the number of even-dominant numbers in the given segment.

예제1

  1. 예제 1

    입력
    1
    1 10
    
    예상 출력
    3