题解:AT_aising2020_f Two Snuke
题意:
对于一个十元组
-
0 \leq a_1 < a_2 -
0 \leq b_1 < b_2 -
0 \leq c_1 < c_2 -
0 \leq d_1 < d_2 -
0 \leq e_1 < e_2 -
a_1 + a_2 + b_1 + b_2 + c_1 + c_2 + d_1 + d_2 + e_1 + e_2 \leq n
现在,给定
分析:
一道考验基本功的题。
为了将
-
\Delta a=a_{2}-a_{1},\Delta b=b_{2}-b_{1},\Delta c =c_{2}-c_{1},\Delta d=d_{2}-d_{1},\Delta e=e_{2}-e_{1} -
A=2a_{1},B=2b_{1},C=2c_{1},d=2d_{1},e=2e_{1}
其中
-
\Delta a,\Delta b\dots\ge1 -
-
很明显需要转化成小球放盒子的问题。
要求
所以我们完成了一个映射:有
最后一个问题,如何保证前
那么对答案的贡献就是:
其中
时间复杂度
代码:
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
namespace Fastio {
const int L = 1 << 20;
inline char gc() {
static char buf[L], *l = buf, *r = buf;
if (l == r)
r = (l = buf) + fread(buf, 1, L, stdin);
return (l == r) ? EOF : *l++;
}
char obuf[L], *p = obuf;
inline void pc(char c) {
if (p == obuf + L)
fwrite(obuf, 1, L, stdout), p = obuf;
*p++ = c;
}
inline void flush() { fwrite(obuf, 1, p - obuf, stdout); }
struct Reader {
template <typename T>
inline Reader& operator>>(T& x) {
x = 0;
short f = 1;
char c = gc();
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = gc();
}
while (isdigit(c)) x = 10 * x + (c - '0'), c = gc();
x *= f;
return *this;
}
Reader() {}
} cin;
struct Writer {
template <typename T>
inline Writer& operator<<(T x) {
if (x < 0)
pc('-'), x = -x;
static short tp = 0, s[40];
do
s[++tp] = x % 10, x /= 10;
while (x);
while (tp) pc(s[tp--] + '0');
return *this;
}
inline Writer& operator<<(const char* s) {
int i = 0;
while (s[i]) pc(s[i++]);
return *this;
}
inline Writer& operator<<(char c) {
pc(c);
return *this;
}
Writer() {}
~Writer() { flush(); }
} cout;
#define cin Fastio::cin
#define cout Fastio::cout
}
int T, n, ans;
int Pow(int a, int n) {
if(n == 0) return 1;
if(n == 1) return a;
int x = Pow(a, n / 2);
if(n % 2 == 0) return x * x % mod;
else return x * x % mod * a % mod;
}
int inv(int x) {
return Pow((x + mod) % mod, mod - 2);
}
int cc[20], Inv[20];
int C(int n, int m) {
if(n < 0 || m < 0 || n < m) return 0;
int res = 1;
for(int i = n; i >= n - m + 1; i--) res = res * i % mod;
return res * Inv[m] % mod;
}
int CC(int n, int m) {
if(n < 0 || m < 0 || n < m) return 0;
int res = 1;
for(int i = n; i >= n - m + 1; i--) res = res * i % mod;
int t = 1;
for(int i = 1; i <= m; i++) t = t * i % mod;
return res * inv(t) % mod;
}
signed main() {
for(int i = 0; i <= 15; i++) cc[i] = CC(11, i);
Inv[0] = 1;
for(int i = 1; i <= 15; i++) Inv[i] = Inv[i - 1] * i % mod;
for(int i = 0; i <= 15; i++) Inv[i] = inv(Inv[i]);
cin >> T;
while(T--) {
cin >> n; ans = 0;
if(n < 5) {
cout << 0 << "\n";
continue;
}
n -= 5;
for(int i = 0; i <= 11; i++) {
if(n < (11 - i)) continue;
int x = (n - (11 - i)) / 2;
if((n - (11 - i)) % 2 == 1) continue;
ans += CC(x + 16 - 1, 16 - 1) * cc[i] % mod;
ans %= mod;
}
cout << ans << "\n";
}
return 0;
}