| Input file: | tilt.in |
| Output file: | tilt.out |
The nodes of a directed graph, called the tilt graph of order X, are the triples (m, n, k), where 0<=m<=X, 0<=n<=X and 1<=k<=3. There are at most four arcs out of node (m, n, k) going to the nodes (n, m+q, min(q, 7-q) ), provided that it is a node of the tilt graph and 1<=q<=6, k<>min(q, 7-q). For example, the node (21, 15, 2) would have arcs going to (15, 22, 1), (15, 24, 3), (15,25, 3) and (15, 27, 1) provided that X>=27.
A node N1 is said to be reachable from N2 if there is a directed path from N2 to N1.
The input to the program will be a sequence of integers to be taken as the value for X, one on each line of the input file. The last input line will contain a 0. The other values for X will be between 1 and 35. Your program is to find the number of nodes which are reachable from (0, 0, 1) in the tilt graph of order X.
15 25 9 0
531 nodes are reachable from (0, 0, 1) in the tilt graph of order 15. 1507 nodes are reachable from (0, 0, 1) in the tilt graph of order 25. 175 nodes are reachable from (0, 0, 1) in the tilt graph of order 9.