版权声明:虽然博主很菜,但是还是请注明出处(我觉得应该没人偷我的博客) https://blog.csdn.net/qq_43346903/article/details/87925793
BZOJ3028
生成函数入门题:
对八个类型分别求生成函数:
A(x)=∑i=0+∞x2i=1−x21
B(x)=1+x
C(x)=1+x+x2
D(x)=∑i=0+∞x2i+1=1−x2x
E(x)=∑i=0+∞x4i=1−x41
F(x)=1+x+x2+x3
G(x)=1+x
H(x)=∑i=0+∞x3i=1−x31
用因式分解把八个生成函数的笛卡尔积求出即为
(1−x)4x
然后用泰勒展开/广义二项式定理推出第n项的系数为
6n(n+1)(n+2)
Code:
#include<bits/stdc++.h>
#define mod 10007
using namespace std;
inline int read(){
int res=0,f=1;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') f=-f;ch=getchar();}
while(isdigit(ch)) {res=((res<<1)+(res<<3)+(ch^48))%mod;ch=getchar();}
return res*f;
}
int n;
int main(){
n=read();
cout<<n*(n+1)%mod*(n+2)%mod*1668%mod;
return 0;
}