ITeye博客

正整数排序 Help is need for Dexter Uva 11384

rex686568 · 2015-01-30 21:07 · Markdown

面对刚开始没有头绪的题目, 先进行尝试往往是非常有必要的,

#include <cstdio>
#include <iostream>

using namespace std;

unsigned int cal(unsigned int n){
	if (n == 1) return 0;
	else if (n == 2) return 1;
	else return cal((unsigned int)(n/2))+1;
}

int main(){

	unsigned int n;
	cin >> n;
	cout << cal(n);
	return 0;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。