#A. 「EZEC-2」异或

    Type: RemoteJudge 1000ms 128MiB

「EZEC-2」异或

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

TT 组询问,每次给定两个正整数 n,ln,l

你需要构造一个长度为 ll 的正整数序列 aa(编号从 11ll),

且满足 i[1,l]\forall i\in[1,l],都有 ai[1,n]a_i\in[1,n]

求:

i=1lj=1i1aiaj\sum_{i=1}^l\sum_{j=1}^{i-1}a_i\oplus a_j

的最大值。

为了避免答案过大,对于每组询问,只需要输出这个最大值对 109+710^9+7 取模的结果。

输入格式

第一行一个整数 TT,表示数据组数。

接下来第 22 行到第 T+1T+1 行,每行两个整数 n,ln,l ,分别代表 aia_i 的最大取值与 aa 的长度。

输出格式

TT 行,每行一个整数,对应每组询问的答案对 109+710^9+7 取模的结果。

1
2 3

6
2
114 514
1919 180

8388223
16580700

提示

【样例解释 #1】
n=2,l=3n=2,l=3aa{1,2,1}\{1,2,1\} 的任一排列时可以得到最大值,为 (12)+(11)+(21)=6(1\oplus2)+(1\oplus1)+(2\oplus1)=6,易证明此时原式有最大值。


【数据规模与约定】

测试点编号 TT\le nn\le ll\le
151\sim5 11 1010 55
66 5×1055\times 10^5 101210^{12} 22
77 33
8108\sim10 10510^5

对于 100%100\% 的数据,满足 1T5×1051\le T\le 5\times10^51n10121\le n\le 10^{12}2l1052\le l \le 10^5


【提示】

  1. \oplus」是按位异或符号。如果您不知道什么是按位异或,可以参考这里
  2. 取模是一种运算,aabb 取模代表将 aa 赋值为 aa 除以 bb 所得到的余数。
    在 C++ / Python 中的取模符号为 %,在 Pascal 中的取模符号为 mod
  3. \sum 是求和符号。如果您不知道什么是 \sum 符号,可以参考这里
  4. 请注意数据的读入输出对程序效率造成的影响。

20241217集训

Not Attended
Status
Done
Rule
IOI
Problem
5
Start at
2024-12-17 17:00
End at
2024-12-17 21:30
Duration
4.5 hour(s)
Host
Partic.
13