bzoj 3028 母函数

  首先我们可以求出来所有食物的母函数:

  汉堡:f(x)=1/(1-x^2)。

  可乐:f(x)=1+x.

  鸡腿:f(x)=1+x+x^2.

  蜜桃多:f(x)=x/(1-x^2).

  鸡块:f(x)=1/(1-x^4).

  包子:f(x)=1+x+x^2+x^3.

  土豆片炒肉:f(x)=1+x.

  面包:f(x)=1/(1-x^3).

  然后我们可以将他们全乘起来,得到f(x)=x/(1-x)^4.然后根据泰勒展开1/(1-x)^n=1+C(n,1)x^1+C(n+1,2)x^2+C(n+2,3)x^3+...+C(n+k-1,k)x^k+...。

  可以得到第n项的系数为c(n+2,3),根据卷积原理,这个就是最后的答案。

/**************************************************************
    Problem: 3028
    User: BLADEVIL
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:804 kb
****************************************************************/
 
//By BLADEVIL
#include <cstdio>
#include <cstring>
#define d39 10007
 
using namespace std;
 
char a[510];
 
int main() {
    int ans=0;
    scanf("%s",a); int len=strlen(a);
    for (int i=0;i<len;i++) ans=(ans*10+a[i]-'0')%d39;
    ans=ans*(ans+1)%d39*(ans+2)%d39*1668%d39;
    printf("%d\n",ans);
    return 0;
}

 

 

posted on 2014-03-29 17:20  BLADEVIL  阅读(441)  评论(0编辑  收藏  举报