本文主要是介绍传球游戏【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 3≤n≤30,1≤m≤20
对于 100 % 100\% 100%的数据满足, 3 ≤ n ≤ 30 , 1 ≤ m ≤ 30 3\leq n \leq 30, 1 \leq m \leq 30 3≤n≤30,1≤m≤30
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=Fi−1,j−1+Fi−1,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;
}
这篇关于传球游戏【Ybtoj】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!