CF1036C.Classy Numbers

普及+/提高

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's call some positive integer classy if its decimal representation contains no more than 33 non-zero digits. For example, numbers 44, 200000200000, 1020310203 are classy and numbers 42314231, 102306102306, 72774200007277420000 are not.

You are given a segment [L;R][L; R]. Count the number of classy integers xx such that L≤x≤RL \le x \le R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

我们称某个正整数为“优雅数”(classy),如果其十进制表示中至多包含 33 个非零数字。例如,数字 44、200000200000、1020310203 是优雅数,而数字 42314231、102306102306、72774200007277420000 不是。

给定一个区间 [L;R][L; R]。请计算满足 L≤x≤RL \le x \le R 的优雅数 xx 的个数。

每个测试用例包含多个区间,对每个区间你都需要独立求解该问题。

输入格式

The first line contains a single integer TT (1≤T≤1041 \le T \le 10^4) — the number of segments in a testcase.

Each of the next TT lines contains two integers LiL_i and RiR_i (1≤Li≤Ri≤10181 \le L_i \le R_i \le 10^{18}).

第一行包含一个整数 TT(1≤T≤1041 \le T \le 10^4)—— 表示测试用例中线段的数量。

接下来的 TT 行,每行包含两个整数 LiL_i 和 RiR_i(1≤Li≤Ri≤10181 \le L_i \le R_i \le 10^{18})。

输出格式

Print TT lines — the ii-th line should contain the number of classy integers on a segment [Li;Ri][L_i; R_i].

输出 TT 行——第 ii 行应包含区间 [Li;Ri][L_i; R_i] 中“优雅整数”(classy integers)的个数。

输入输出样例

  • 输入#1

    4
    1 1000
    1024 1024
    65536 65536
    999999 1000001

    输出#1

    1000
    1
    0
    2

输入解题思路,AI测评打分。不知道怎么写?

首页