Problem:
Score : 800 points

Problem Statement

Snuke has a string x of length N.
Initially, every character in x is 0.

Snuke can do the following two operations any number of times in any order:

Choose A consecutive characters in x and replace each of them with 0.

Choose B consecutive characters in x and replace each of them with 1.

Find the number of different strings that x can be after Snuke finishes doing operations.
This count can be enormous, so compute it modulo (10^9+7).

Constraints

1 \leq N \leq 5000

1 \leq A,B \leq N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of different strings that x can be after Snuke finishes doing operations, modulo (10^9+7).

Sample Input 1

4 2 3

Sample Output 1

11

For example, x can be 0011 or 1111 in the end, but cannot be 0110.

Sample Input 2

10 7 2

Sample Output 2

533

Sample Input 3

1000 100 10

Sample Output 3

828178524

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

#define DEBUG 1

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 1000000007

LLI dp[5001][2],dp2[5001][2];
int main() {
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    if (A > B) swap(A,B);
    if (A == 1) {
        int i,p = 1;
        for (i = 0; i < N; i++) p *= 2,p %= MOD;
        printf("%d\n",p);
        return 0;
    }

    int i,j;
    dp[1][1] = 1;
    for (i = 2; i <= N; i++) {
        dp[i][1] = dp[i-1][0]+dp[i-1][1];
        for (j = A; j < i; j++) dp[i][0] += dp[i-j][1];
        dp[i][0] %= MOD,dp[i][1] %= MOD;
    }
    dp2[0][0] = dp2[0][1] = 1;
    for (i = 1; i <= N; i++) {
        for (j = 1; j <= i; j++) {
            if (j < A) dp2[i][0] += dp2[i-j][1];
            if (j < B) {
                dp2[i][1] += (dp2[i-j][0]*dp[j][1]) % MOD;
                if (i == N) dp2[i][1] += (dp2[i-j][0]*dp[j][0]) % MOD;
                if (j == i) dp2[i][1] += dp[j][0];
            }
        }
        dp2[i][0] %= MOD,dp2[i][1] %= MOD;
    }
    int p = 1;
    for (i = 0; i < N; i++) p *= 2,p %= MOD;
    printf("%lld\n",(p-(dp2[N][0]+dp2[N][1])+2*MOD) % MOD);

    return 0;
}