Ada Loveslaces

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

A shoe has a lacing geometry: NN, the number of eyelets (on a side), dd, the distance between eyelets, ss, the separation between the columns of eyelets when the shoe is laced, and tt, the thickness of an eyelet. In Figure 1 below, N=3N = 3, with eyelets numbered from 00 to 2N12N - 1.

Figure 1: Eyelet numbering and dimensions for N=3N = 3.

When laced, a shoelace of length LL will have two free ends for knot tying. The free length of each end is ff.  The length of ff must fall within a certain range, \[f_min,f_max]\[f\_{min}, f\_{max}] to accommodate a knot that is neither too small to tie nor so large as to dangle.  See Figure 2 for a common criss-cross pattern.

Figure 2: Criss-cross lacing pattern showing free end length ff.

That special end of a lace that prevents fraying is called an "aglet." You're welcome.

Unfortunately, shoelaces break at the most inopportune times.  Before purchasing a new shoelace, it is often necessary to retie the shorter, broken lace, or replace it with another lace borrowed from another shoe.

Given N,d,s,t,f_min,f_maxN, d, s, t, f\_{min}, f\_{max}, and a series of replacement shoelace lengths, LL, for each shoelace length determine the number of lacing patterns that leave free ends, ff, such that f_minff_maxf\_{min} \le f \le f\_{max}.  The rules of lacing are as follows:

  • The resulting lacing pattern must be symmetric across a line drawn vertically between the even-numbered and odd-numbered eyelets.
  • The lace can only pass through an eyelet at most once.
  • The lace can only pass between eyelets in the same column that are immediately adjacent.
  • The free ends of the lace must emerge from eyelet numbers 2N22N - 2 and 2N12N - 1.
  • The lace must pass directly between eyelet numbers 0 and 1 to ensure the shoelace holds the shoe on the foot.

You are to assume that the surface the eyelets are on is to be treated as a plane, that the shoelace passes through the center of the eyelets, and that the thickness of the shoelace itself is negligible. The total length of the shoelace that is used for lacing is the length used between the eyelets plus tt for each eyelet the shoelace passes through.  In the example shown in Figure 2, 6t6t of the shoelace length is used by passing through the six eyelets.

입력

The input begins with a single line containing N,d,s,t,f_min,f_maxN, d, s, t, f\_{min}, f\_{max}, separated by whitespace.  Each additional line is a new value of LL for which your program is to count the number of lacing patterns that meet the stated requirements.  There will be between 11 and 100100 values of LL. All measurements are in integer millimeters.

NN will be between 22 and 99 inclusive.  dd will be between 55 and 3030 inclusive. ss will be between 1010 and 5050 inclusive.  tt will be between 00 and 44 inclusive.  f_minf\_{min} and f_maxf\_{max} satisfy 0f_minf_max2,0000 \leq f\_{min} \leq f\_{max} \leq 2\\,000. Shoelace lengths will be between 200200 and 2,0002\\,000 millimeters inclusive.  f_minf\_{min} and f_maxf\_{max} will not be within a micron (0.0010.001 millimeters) of the free end lengths of a valid lacing pattern.

출력

For each shoelace length, your program is to print the number of possible lacing patterns that meet the above requirements. Values are to be separated from each other by newlines and/or spaces.