Problem C. Cube number on a tree
时间限制 10000 ms
内存限制 63.9990234375 MB
The country Tom living in is famous for traveling. Every year, many tourists from all over the world have interests in traveling there.
There are n provinces in the country. According to the experiences from the tourists came before, every province has its own preference value. A route’s preference value from one province to another is defined as the product of all the preference value of the provinces on the route. It’s guaranteed that for each two provinces in the country there is a unique route from one to another without passing any province twice or more.
Tom is a boy crazy about cube number. A cube number is a positive integer whose cube root is also an integer. He is planning to travel from a province to another in the summer vacation and he will only choose the route with the cube number preference value. Now he want to know the number of routes that satisfy his strange requirement.
输入数据
输出数据
For each test case, print a number indicating the number of routes that satisfy the requirement.
样例输入
复制
5
3 2 3 5
2500 200 9 270000 27
4 2
3 5
2 5
4 1
样例输出
$ Mathjax font initiator $