Sunday, September 8, 2013

UVa 11384 - Help is needed for Dexter

Accepted date: 2013-09-07
Ranking (as of 2013-09-08): 672 out of 764
Language: C++

/*
  UVa 11384 - Help is needed for Dexter

  To build using Visual Studio 2012:
    cl -EHsc -O2 UVa_11384_Help_is_needed_for_Dexter.cpp
*/

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  const double log2 = log(2.0);
  int n;
  while (cin >> n)
    cout << static_cast<int>(log(static_cast<double>(n)) / log2) + 1 << endl;
      // log2(n) + 1
  return 0;
}

No comments:

Post a Comment