【BZOJ 3028】 3028: 食物 (生成函式)
阿新 • • 發佈:2018-12-30
然後等比數列求和 ($x^{inf}=0$)
$=\dfrac{1−x^2}{1−x}*\dfrac{1−x^2}{1−x}*\dfrac{1−x^3}{1−x}*\dfrac{1−x^4}{1−x}*\dfrac{1}{1−x^2}*\dfrac{x}{1−x^2}*\dfrac{1}{1−x^4}*\dfrac{1}{1−x^3} $
$=\dfrac{x}{(1−x)^{4}}$
【打得有點辛苦
然後$G(x)=\dfrac{1}{(1-x)^m}=(1+x+x^2+x^3+...)^m$的x^n的係數是,把n分成m分可空的。即$C_{n+m-1}^{m-1}$
然後乘一個x,就是第n-1項的係數即為答案,即$C_{n-1+4-1}^{4-1}=C_{n+2}^{3}=\dfrac{n*(n+1)*(n+2)}{6}$
【生成函式做這道題感覺很優越啊。。
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 #define Mod 10007 8 #define LL long long 9 10 char s[510]; 11 12 int main() 13 { 14 scanf("%s",s); 15 intView Codel=strlen(s),n=0; 16 for(int i=0;i<l;i++) 17 { 18 n=n*10+s[i]-'0'; 19 n%=Mod; 20 } 21 n=1LL*n*(n+1)*(n+2)/6%Mod; 22 printf("%d\n",n); 23 return 0; 24 }
2017-04-25 22:12:06