51nod 1486 大大走格仔

2021-08-21 22:10:57 字數 656 閱讀 1420

sol:

考慮沒有障礙的情況,從(1,1)到(n,m)答案可直接算出為

可得到遞推式

code:

#include #include #include #include #include #include #include #include #include #include using namespace std;

typedef long long ll;

const int maxn = 3e3 + 50;

const ll mod = 1e9 + 7;

ll fac[maxn];

ll inv[maxn];

inline ll qpow(ll a, ll b)

return sum;

}inline ll lnv(int n)

void init(int n)

inv[n] = lnv(fac[n]);

for (int i = n - 1; i > 1; i--)

}inline ll c(int n, int m)

struct node

// cout<

}printf("%lld\n",dp[n]);

return 0;

}

51nod 1486 大大走格仔

1486 大大走格仔 codeforces 基準時間限制 1 秒 空間限制 131072 kb 分值 160 難度 6級演算法題 有乙個h行w列的棋盤,裡面有一些格仔是不能走的,現在要求從左上角走到右下角的方案數。input 單組測試資料。第一行有三個整數h,w,n 1 h,w 10 5,1 n 2...

51nod 1486 大大走格仔

1486 大大走格仔 基準時間限制 1 秒 空間限制 131072 kb 有乙個h行w列的棋盤,裡面有一些格仔是不能走的,現在要求從左上角走到右下角的方案數。input 單組測試資料。第一行有三個整數h,w,n 1 h,w 10 5,1 n 2000 表示棋盤的行和列,還有不能走的格仔的數目。接下來...

51Nod 1486 大大走格仔 容斥

題目 對於每個點,求出從起點到它,不經過其他障礙點的方案數 求乙個點時,首先得到走到它的所有方案,減去 x y 都小於它的點的方案 走到該點的方案數 由於該點的方案也不包括其它障礙點,所以就是容斥。如下 include include include include using namespace ...