洛谷P1057

#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
#define fi(i,a,b) for(int i = a; i <= b; ++i)
#define fr(i,a,b) for(int i = a; i >= b; --i)
#define x first
#define y second
#define sz(x) ((int)(x).size())
#define pb push_back
using pii = pair<int,int>;
int dp[35][35];
//#define DEBUG
int n,m;
int check(int x){
    if(x >= 1 && x <= n) return x;
    if(x < 1) return x + n;
    if(x > n) return x % n;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    dp[0][1] = 1;
    fi(i,1,m){
        fi(j,1,n){
            dp[i][j] = dp[i-1][check(j-1)] + dp[i-1][check(j+1)];
        }
    }
    cout << dp[m][1] << endl;
#ifdef DEBUG
    //freopen(D:\in.txt,r,stdin);
#endif
    return 0;
}
posted @ 2022-02-23 20:32  Sun-Wind  阅读(20)  评论(0编辑  收藏  举报