RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00392

San

Unrated 레이팅 미적용
난이도
5s
시간 제한
64MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(6^{th}\) round, February \(6^{th}\) 2016
Anica is having peculiar dream. She is dreaming about an infinite board. On that board, an infite table
consisting of infinite rows and infinite columns containing infinite numbers is drawn. Interestingly, each
number in the table appears a finite number of times.
The table is of exceptionally regular shape and its values meet the requirements of a simple recursive
relation. The first cell of each row contains the ordinal number of that row. A value of a cell that is
not in the first column can be calculated by adding up the number in the cell to the left of it and that
same number, only written in reverse (in decimal representation).
Formally, if \(A\)(i, j) denotes the value in the \(i\)^{th} row and the \(j\)^{th} column, it holds:
\(A\)(i, 1) = \(i\)
\(A\)(i, j) = \(A\)(i, \(j - 1\)) + rev^{1}(\(A\)(i, \(j - 1\))), for each \(j > 1\)
1
2
4
8
16
77
154
2
4
8
16
77
154
605
3
6
12
33
66
132
363
. . .
4
8
16
77
154
605
1111
5
10
11
22
44
88
176
...
...
The first few rows and columns \(of\) the table.
Notice that the table \(is\) infinite only \(in\) 2 directions.
Anica hasn’t shown too much interest in the board and obliviously passed by it. Behind the board,
she noticed a lamp that immediately caught her attention. Anica also caught the lamp’s attention, so
the friendly ghost Božo came out of it.
“Anica! If you answer correctly to my \(Q\) queries, you will win a package of Dorina wafer or Domaćica
cookies, based on your own choice! I wouldn’t want to impose my stance, but in my personal opinion,
the Dorina wafer cookies are better. Each query will consist of two integers \(A\) and \(B\). You must answer
how many appearances of numbers from the interval [A, B] there are on the board.”
Unfortunately, Anica couldn’t give an answer to the queries and woke up.
“Ah, I didn’t win the Dorina cookies, but at least I have a task for COCI”, she thought and went along
with her business.

제약

In test cases worth 50% of total points, it will hold (1 ⩽A, B ⩽\(10^{6}\)).
^{1}rev(\(x\)) denotes the number \(x\) written in reverse in decimal representation. For example, rev(213) = 312, rev(406800)
= \(008604 = 8604\).
\(6^{th}\) round, February \(6^{th}\) 2016

입력 형식

The first line of input contains the integer \(Q\) (1 ⩽\(Q\)\(10^{5}\)), the number of queries.
Each of the following \(Q\) lines contains two integers \(A\) and \(B\) (1 ⩽\(A\)\(B\)\(10^{10}\)) that represent the
interval from the query.

출력 형식

The \(i\)^{th} line of output must contain a single integer – the answer to the \(i\)^{th} query.

예제 1
입력
2
1 10
5 8
3
17 144
121 121
89 98
1
1 1000000000
출력
output
output
18
8
265
25
10
1863025563
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2015/2016 Contest 6

평가 및 의견

San

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

San

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8