programming-challengs The Archeologists'Dilemma(110503)問題解
この問題の難易度は1ですが、私には難しいので、インターネットで見つけた方法を参考にしましたが、googleはまた掛けて、後で解法の投稿urlを投稿します.基本的にlog演算を用いて,答えを探す操作の過程を簡略化した.コードは次のとおりです.
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <assert.h>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <functional>
#include <string.h>
#include <stdio.h>
#include <numeric>
#include <float.h>
using namespace std;
int main() {
long long l;
while (cin >> l) {
long long t = ceil(log10(l) + 1);
if (fabs((int)log10(l) - log10(l)) < DBL_EPSILON) {
t++;
}
do {
long long l1 = ceil((log10(l) + t) / log10(2));
long long l2 = ceil((log10(l + 1) + t) / log10(2));
if (l1 < l2) {
cout << l1 << endl;
break;
}
t++;
} while (true);
}
return 0;
}