ID προβλήματος: pn_sterms
Τίτλος: Θετικά Αρνητικά S-Terms
Βαθμός Δυσκολίας: 5
Ημερομηνία Εισαγωγής: 2000-06-04
Σχόλια:

Θετικά Αρνητικά S-Terms

An S-Term is defined recursively as follows: "S" (without the quotes) is an S-Term and if N and M and S-terms, then "(NM)" (without the quotes) is also an S-Term. The length of an S-Term is the number of "S" it contains.

Write a program that reads an integer N from the standard input. If N is between -10 and -1 including, then output the number of s-terms with length abs(N), in one line. If N is between 1 and 10 (including), then output all the sterms with length N


Παραδείγματα εισόδου/εξόδου
ΕίσοδοςΈξοδος
5
(S(S(S(SS))))
(S(S((SS)S)))
(S((SS)(SS)))
(S((S(SS))S))
(S(((SS)S)S))
((SS)(S(SS)))
((SS)((SS)S))
((S(SS))(SS))
(((SS)S)(SS))
((S(S(SS)))S)
((S((SS)S))S)
(((SS)(SS))S)
(((S(SS))S)S)
((((SS)S)S)S)
-5
14