Friday, October 9, 2015

UVa 10916 - Factstone Benchmark

// UVa 10916 - Factstone Benchmark

#include <iostream>
#include <math.h>
using namespace std;

#define ll unsigned long long

int main() {
	int year;
	while (cin >> year && year) {
		int e = (year - 1960) / 10 + 2;
		ll n = pow(2.0, e);
		double lim = n * log(2);
		double fact = 0;
		ll sol = 0;
		for (ll i = 1; i <= n; i++) {
			fact += log(i);
			if (fact >= lim) {
				sol = i - 1;
				break;
			}
		}
		cout << sol << endl;
	}
	return 0;
}

No comments:

Post a Comment