Counting Music Scores
Time limit2sMemory limit512 MB
Count scores over two pitches and two durations with n seconds total, balanced pitch counts, at least as many long notes as short, and alternating pitches starting low.
- Level
Medium5 of 10
- Topics
- Combinatorics, Dynamic programming, Math
- Solved
- No attempts yet
Problem
You build a musical score by writing notes one after another. Each note has one of two pitches, low or high, and one of two durations, short or long. A short note lasts 1 second and a long note lasts 2 seconds. The score must satisfy all of the following.
a) The total duration of the score is a given integer seconds.
b) The number of low short notes equals the number of high short notes.
c) The number of low long notes equals the number of high long notes.
d) The number of long notes is at least the number of short notes.
e) Low notes and high notes alternate.
f) The first note is low.
Given an even integer , count the scores that satisfy every condition. Writing each note as its duration, the 4 scores for are 2211, 2112, 1221 and 1122. Conditions e and f force every odd numbered note to be low and every even numbered note to be high. For the only score is 2222.
Input
The first line contains the number of test cases ().
Each of the next lines contains one even integer ().
Output
For each test case, print on its own line the number of scores that satisfy every condition. The answer is smaller than .