傳球遊戲【Ybtoj】
阿新 • • 發佈:2020-12-30
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;
}