HDU6288

版权声明:晓程原创 https://blog.csdn.net/qq_43469554/article/details/88637359

缺失数据范围
http://acm.hdu.edu.cn/status.php?first=&pid=4004&user=&lang=0&status=0

#include <iostream>
#include <cmath> 
#define ull unsigned long long int
using namespace std;
int a, b;
ull k;
ull log(ull n)
{
	return ceil(log2(n));
}
bool check(ull x)
{
	ull ans = 1;
	for (int i = 0; i < a; i++)
	{
		ans *= x;
		if (ans > k)
		{
			return false;
		}
		
	}
	for (int i = 0; i < b; i++)
	{
		ans *= log(x);
		if (ans > k)
		{
			return false;
		}
	}
	return true;
}
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		ull l = 0, r = 1e18, mid;
		ull ans;
		cin >> a >> b >> k;
		while(l <= r)
		{
			mid = (l + r) / 2;
			if (check(mid))
			{
				l = mid + 1;
				ans = mid;
			}
			else
			{
				r = mid - 1;
			}
		} 
		cout << ans << endl;
	}
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/qq_43469554/article/details/88637359
hdu