编程介的小学生 2019-01-31 15:14 采纳率: 20.5%
浏览 191

质数分解二叉树的一个问题,数据结构问题怎么采用C语言的实现

Problem Description
Given an integer n, it generates a tree by the following operation.

Initially, there is a node weights n.

If n is not a prime number, the nodes gets a left son and a right son, the left son weights x, where x is a factor of n and x is larger than 1 and smaller than n chosen randomly, and the right son weights n/x. We call this step split.

For each leaf of tree, we do the split operation, until all of the leaves weight a prime number.

For example, suppose n to be 12, and the picture below shows a tree generated.

Now we want to know the expectated height of the tree.

Input
There are multiply test cases.

The first line contains an integer T(T<=50000), which denotes the number of test cases.

For each test case, there is an integer n(2<=n<=10^11), denotes the weight of the root.

The test cases are generated almost randomly.

Output
For each test case, output “Case #k: ”first, k is the case number, from 1 to T , and then output the expectated height. The answer should be rounded after the sixth decimal place.

Sample Input
3
2
4
36

Sample Output
Case #1: 1.000000
Case #2: 2.000000
Case #3: 3.571429

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler