Codeforces Round 940 (Div. 2) and CodeCraft-23
E
Carousel of Combinations
Codeforces
2400
原题
← DF1 →
翻译中…

You are given an integer $n$. The function $C(i,k)$ represents the number of distinct ways you can select $k$ distinct numbers from the set {$1, 2, \ldots, i$} and arrange them in a circle$^\dagger$.

翻译中…

Find the value of $$ \sum\limits_{i=1}^n \sum\limits_{j=1}^i \left( C(i,j) \bmod j \right). $$ Here, the operation $x \bmod y$ denotes the remainder from dividing $x$ by $y$.

翻译中…

Since this value can be very large, find it modulo $10^9+7$.

翻译中…

$^\dagger$ In a circular arrangement, sequences are considered identical if one can be rotated to match the other. For instance, $[1, 2, 3]$ and $[2, 3, 1]$ are equivalent in a circle.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \leq t \leq 10^5$) — the number of test cases.

翻译中…

The only line of each test case contains a single integer $n$ ($1 \le n \le 10^6$).

翻译中…

Output

翻译中…

For each test case, output a single integer on a new line — the value of the expression to be calculated modulo $10^9+7$.

翻译中…

Note

翻译中…

In the first test case, $C(1,1) \bmod 1 = 0$.

翻译中…

In the second test case:

翻译中…
  • $C(1,1)=1$ (the arrangements are: $[1]$);
  • $C(2,1)=2$ (the arrangements are: $[1]$, $[2]$);
  • $C(2,2)=1$ (the arrangements are: $[1, 2]$);
  • $C(3,1)=3$ (the arrangements are: $[1]$, $[2]$, $[3]$);
  • $C(3,2)=3$ (the arrangements are: $[1, 2]$, $[2, 3]$, $[3, 1]$);
  • $C(3,3)=2$ (the arrangements are: $[1, 2, 3]$, $[1, 3, 2]$).
翻译中…

In total, $\left(C(1,1) \bmod 1\right) + \left(C(2,1) \bmod 1\right) + \left(C(2,2) \bmod 2\right) + \left(C(3,1) \bmod 1\right) + \left(C(3,2) \bmod 2\right) + \left(C(3,3) \bmod 3\right) = 4$.

翻译中…

样例

Input #1
4
1
3
6
314159
Output #1
0
4
24
78926217
InputCopy OutputCopy
题目信息
题号
1957E
时间限制
2.5 s
内存限制
256 MB
标签
暴力
组合数学
动态规划
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。