Wednesday, November 4, 2015

UVa 11714 - Blind Sorting

Accepted date: 2015-11-04
Ranking (as of 2015-11-04): 7 out of 591
Language: C++11

/*
  UVa 11714 - Blind Sorting

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

#include <cstdio>
#include <cmath>

int main()
{
  long long n;
  while (scanf("%lld", &n) != EOF)
    printf("%lld\n",
      n + static_cast<long long>(ceil(log2(static_cast<double>(n)))) - 2);
  return 0;
}

No comments:

Post a Comment