传球游戏【Ybtoj】

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

I n p u t Input Input

一行,有两个用空格隔开的整数n,m。

O u t p u t Output Output

1个整数,表示符合题意的方法数。

S a m p l e Sample Sample I n p u t Input Input
3 3
S a m p l e Sample Sample O u t p u t Output Output
2

H i n t Hint Hint

对于 40 % 40\% 40%的数据满足, 3 ≤ n ≤ 30 , 1 ≤ m ≤ 20 3\leq n \leq 30, 1 \leq m \leq 20 3n30,1m20
对于 100 % 100\% 100%的数据满足, 3 ≤ n ≤ 30 , 1 ≤ m ≤ 30 3\leq n \leq 30, 1 \leq m \leq 30 3n30,1m30

T r a i n Train Train o f of of T h o u g h t Thought Thought

啊这
F i , j = F i − 1 , j − 1 + F i − 1 , j + 1 F_{i,j}=F_{i-1,j-1}+F_{i-1,j+1} Fi,j=Fi1,j1+Fi1,j+1

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll long long 
using namespace std;

ll F[105][105];
ll n, m;

int main()
{
	scanf("%lld%lld", &n, &m);
	F[0][1] = 1;
	for(int i = 1; i <= m; ++i)
		for(int j = 1;j <= n; ++j)
		{
 			int x = (j - 1 >= 1) ? j - 1 : n;
			int y = (j + 1 <= n) ? j + 1 : 1;
			F[i][j] = F[i - 1][x] + F[i - 1][y];
		}
	printf("%lld", F[m][1]);
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值