Given an array A[] of **N** integers, where each integer is greater than 1.The task is to find the number of Full binary tree from the given integers, such that each non leaf node value is the product of its children value.

**Note:** Each integer can be used multiple times in a full binary tree.

**Input:**

The first line of input contains an integer **T** denoting the no of test cases. Then T test cases follow. Each line contains an integer N denoting the size of the array A[]. Then in the next line are N space separated values of the array A[].

**Output:**

For each test case in a new line print an integer denoting the result.

**Constraints:**

1 <= T <= 100

1 <= N <= 100

**Example:
Input:**

2

4

2 3 4 6

3

2 4 5

**Output:**

7

4

**Explanation:
Testcase 1:**

There are 7 full binary tree with the given product property.

// Four trees with single nodes

2 3 4 6

// Three trees with three nodes

4 ,

/ \

2 2

6 ,

/ \

2 3

6

/ \

3 2

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

agness | 122 |

aman1931998 | 102 |

Survivor | 100 |

uchitnitk | 96 |

lonecoder | 95 |

KshatriyaYash | 1066 |

nikhil_sojan | 1032 |

lonecoder | 1030 |

mazumderrohit8 | 899 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4492 |

Quandray | 4444 |

Login to report an issue on this page.