UVa11714 - Blind Sorting

#include <iostream>
#include <cmath>
#include <fstream>

using namespace std;

int main()
{
	int n;

	#ifndef ONLINE_JUDGE
		ifstream fin("d:\\OJ\\uva_in.txt");
		streambuf *old = cin.rdbuf(fin.rdbuf());
	#endif

	while (cin >> n) {
		cout << n + (int)ceil(log2(n)) - 2 << endl;
	}

	#ifndef ONLINE_JUDGE
		cin.rdbuf(old);
	#endif

	return 0;
}

你可能感兴趣的:(UVa11714 - Blind Sorting)