2019.4.27 提高B组 T3 nssl-1318 地铁重组

D e s c r i p t i o n Description Description

n n n个数要入栈然后出栈,但这个栈只能容纳 m m m个数,求出栈顺序数,对4096取模

n , m ≤ 2000 n,m\leq 2000 n,m2000


S o l u t i o n Solution Solution

原题啊。。。


C o d e Code Code
#include<queue>
#include<cstdio>
#include<cctype>
#define LL long long
using namespace std;int n,m,f[2001][2001];
inline LL read()
{
    char c;int f=0,d=1;
    while(c=getchar(),!isdigit(c)) if(c=='-') d=-1;f=(f<<3)+(f<<1)+c-48;
    while(c=getchar(),isdigit(c)) f=(f<<3)+(f<<1)+c-48;
    return d*f;
}
signed main()
{
	n=read();m=read();f[0][0]=1;
	for(register int i=0;i<=n;i++)
	 for(register int j=0;j<=m;j++)
	{
		if(i+j==0) continue;
		if(j<m&&i!=0) (f[i][j]+=f[i-1][j+1]+f[i][j-1])&=0xfff;
	    else (f[i][j]+=f[i][j-1])&0xfff;
	}
	printf("%d",f[n][0]&0xfff);
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值