#include <iostream> using namespace std; typedef long long LL; const LL MOD = 1e9 + 7; // 模数 const int N = 1000010; // n的最大值加一些余量 LL fact[N], invfact[N]; // 快速幂计算a^b % p LL powmod(LL a, LL b, LL p) { LL res = 1; while (b) { if (b & 1) { res = res * a % p; } a = a * a % p; b >>= 1; } ...