首页 > 其他 > 详细

Utopian Tree

时间:2014-09-25 23:14:39      阅读:322      评论:0      收藏:0      [点我收藏+]

Utopian Tree

#include <iostream>
using namespace std;

int height(int n) {
    if(n == 0)
        return 1;
    else
        {
        if(n % 2 == 0)
            return height(n - 1)+1;
        else
            return height(n - 1)*2;
        
    }
    
    return 0;
}
int main() {
    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        cout << height(n) << endl;
    }
}


Utopian Tree

原文:http://9320314.blog.51cto.com/9310314/1558247

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!