package main import ( "bufio" "fmt" "os" "strconv" ) func configure(scanner *bufio.Scanner) { scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) } func getNextString(scanner *bufio.Scanner) string { scanned := scanner.Scan() if !scanned { panic("scan failed") } return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout extra := 0 if os.Getenv("I") == "IronMan" { fp, _ = os.Open(os.Getenv("END_GAME")) extra = 100 } scanner := bufio.NewScanner(fp) configure(scanner) writer := bufio.NewWriter(wfp) defer func() { r := recover() if r != nil { fmt.Fprintln(writer, r) } writer.Flush() }() solve(scanner, writer) for i := 0; i < extra; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { t := getNextInt(scanner) a := getNextInt(scanner) b := getNextInt(scanner) c := getNextInt(scanner) d := getNextInt(scanner) e := getNextInt(scanner) geta := 10000 dp := make([]mint, geta*2+1) dp[geta] = 1 for i := 0; i < t; i++ { dp2 := make([]mint, geta*2+1) for j := 0; j < geta*2+1; j++ { if dp[j] == 0 { continue } dp2[j-a].addAs(dp[j]) dp2[j+a].addAs(dp[j]) dp2[j-b].addAs(dp[j]) dp2[j+b].addAs(dp[j]) dp2[j-c].addAs(dp[j]) dp2[j+c].addAs(dp[j]) } dp = dp2 } var ans mint for i := d; i < e+1; i++ { ans.addAs(dp[i+geta]) } fmt.Fprintln(writer, ans) } type mint int64 func (mt mint) mod() mint { m := mint(1e9 + 7) mt %= m if mt < 0 { return mt + m } return mt } func (mt mint) inv() mint { return mt.pow(mint(0).sub(2)) } func (mt mint) pow(n mint) mint { p := mint(1) for n > 0 { if n%2 == 1 { p.mulAs(mt) } mt.mulAs(mt) n >>= 1 } return p } func (mt mint) mintize(x interface{}) mint { if y, isMint := x.(mint); isMint { return y } if y, isInt64 := x.(int64); isInt64 { return mint(y) } return mint(x.(int)) } func (mt mint) add(x interface{}) mint { return (mt + mt.mintize(x)).mod() } func (mt mint) sub(x interface{}) mint { return (mt - mt.mintize(x)).mod() } func (mt mint) mul(x interface{}) mint { return (mt * mt.mintize(x)).mod() } func (mt mint) div(x interface{}) mint { return mt.mul(mt.mintize(x).inv()) } func (mt *mint) addAs(x interface{}) *mint { *mt = mt.add(x) return mt } func (mt *mint) subAs(x interface{}) *mint { *mt = mt.sub(x) return mt } func (mt *mint) mulAs(x interface{}) *mint { *mt = mt.mul(x) return mt } func (mt *mint) divAs(x interface{}) *mint { *mt = mt.div(x) return mt }