CF1891D.Suspicious logarithms

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Let ff(xx) be the floor of the binary logarithm of xx. In other words, ff(xx) is largest non-negative integer yy, such that 2y2^y does not exceed xx.

Let gg(xx) be the floor of the logarithm of xx with base ff(xx). In other words, gg(xx) is the largest non-negative integer zz, such that f(x)z{f(x)}^{z} does not exceed xx.

You are given qq queries. The ii-th query consists of two integers lil_i and rir_i. The answer to the query is the sum of gg(kk) across all integers kk, such that li≤k≤ril_i \leq k \leq r_i. Since the answers might be large, print them modulo 109+7{10^9 + 7}.

令 f(x)f(x) 为 xx 的二进制对数(即以 22 为底的对数)的下取整。换言之,f(x)f(x) 是满足 2y≤x2^y \leq x 的最大非负整数 yy。

令 g(x)g(x) 为 xx 以 f(x)f(x) 为底的对数的下取整。换言之,g(x)g(x) 是满足 f(x)z≤x{f(x)}^{z} \leq x 的最大非负整数 zz。

你将收到 qq 个查询。第 ii 个查询包含两个整数 lil_i 和 rir_i。该查询的答案为所有满足 li≤k≤ril_i \leq k \leq r_i 的整数 kk 对应的 g(k)g(k) 值之和。由于答案可能很大,请将结果对 109+7{10^9 + 7} 取模后输出。

输入格式

The first line contains a single integer qq — the number of queries (1≤q≤1051 \leq q \leq 10^5).

The next qq lines each contain two integers lil_i and rir_i — the bounds of the ii-th query (4≤li≤ri≤10184 \leq l_i \leq r_i \leq 10^{18}).

第一行包含一个整数 qq —— 查询的个数(1≤q≤1051 \leq q \leq 10^5)。

接下来的 qq 行,每行包含两个整数 lil_i 和 rir_i —— 第 ii 个查询的边界(4≤li≤ri≤10184 \leq l_i \leq r_i \leq 10^{18})。

输出格式

For each query, output the answer to the query modulo 109+710^9 + 7.

对于每个查询,输出该查询的答案对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    12
    4 6
    4 7
    4 8
    4 100000
    179 1000000000000000000
    57 179
    4 201018959
    7 201018960
    729 50624
    728 50624
    728 50625
    729 50625

    输出#1

    6
    8
    9
    348641
    41949982
    246
    1
    0
    149688
    149690
    149694
    149692

说明/提示

The table below contains the values of the functions ff(xx) and gg(xx) for all xx such that 1≤x≤81 \leq x \leq 8.

xx

11

22

33

44

55

66

77

88

ff

00

11

11

22

22

22

22

33

gg

−-

−-

−-

22

22

22

22

11

下表列出了所有满足 1≤x≤81 \leq x \leq 8 的 xx 对应的函数 f(x)f(x) 和 g(x)g(x) 的值。

xx

11

22

33

44

55

66

77

88

ff

00

11

11

22

22

22

22

33

gg

−-

−-

−-

22

22

22

22

11

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

首页