题目大意: 你要从0层开始, 经过A, 和B层, 到达N层, 每次可以走x或者y层, 输出方法数。
比较简单的dp了吧。。只是处理方式稍微机智点(虽然还是比较好想到的), 递推方程dp[i] = dp[i - x] + dp[i - y],然后输出dp[A] + dp[B - A] + dp[N - B],(事先swap保证A <= B) 。
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
#define ls id<<1,l,mid
#define rs id<<1|1,mid+1,r
#define OFF(x) memset(x,-1,sizeof x)
#define CLR(x) memset(x,0,sizeof x)
#define MEM(x) memset(x,0x3f,sizeof x)
typedef long long ll ;
typedef pair<int,int> pii ;
const int maxn = 1e5+50 ;
const int inf = 0x3f3f3f3f ;
const int MOD = 1e9+7 ;
ll dp[maxn];
int n, x, y, a, b;
int main () {
#ifdef LOCAL
freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
// freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
#endif
while (cin >> n >> x >> y >> a >> b) {
CLR(dp); dp[0] = 1;
for (int i = 1; i <= n; i++) {
if (i >= x) dp[i] = (dp[i] + dp[i - x]) % MOD;
if (i >= y) dp[i] = (dp[i] + dp[i - y]) % MOD;
}
if (a > b) swap(a, b);
printf("%I64d\n", (dp[a] * dp[b - a]) % MOD * dp[n - b] % MOD);
}
return 0;
}