BZOJ3028: 食物

42 篇文章 0 订阅
4 篇文章 0 订阅

好久没有更新博客了话说…
博主并没有退役….

我们写出每种食物的生成函数
承德汉堡: 1+x2+x4....=11x2
可乐: 1+x
鸡腿: 1+x+x2=1x31x
蜜桃多: x+x3+x5....=x1x2
鸡块: 1+x4+x8....=11x4
包子: 1+x+x2+x3=1x41x
土豆片炒肉: 1+x
面包: 1+x3+x6....=11x3

乘一起,约分后得 x(1x)4
展开后第n项的系数就是 C3n+2 ,于是套个Lucas就可以了

code:

#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e15
using namespace std;

const int Mod = 10007;
const int maxn = 1100;

int n;
char str[maxn];
int c[Mod+1][4];

int main()
{   
    c[0][0]=1ll;
    for(int i=1;i<=Mod;i++)
    {
        c[i][0]=1ll;
        for(int j=1;j<=3;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%Mod;
    }

    scanf("%s",str); int len=strlen(str);
    for(int i=0;i<len;i++) n=(n*10+str[i]-'0')%Mod;
    n+=2; n%=Mod;
    printf("%d\n",c[n][3]);

    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值