Codeforces 1288A Deadline

题目链接:

Codeforces 1288A Deadline

思路:

即求 x + c e i l ( d x + 1 ) x+ceil(\frac{d}{x+1}) 的最小值会不会超过 n n
用不等式 a + b 2 a b a+b\leq2\sqrt{ab} 可求得左式的最小值即为 2 c e i l ( d ) 1 2ceil(\sqrt{d})-1

代码:

#include<bits/stdc++.h>

using namespace std;

int main() {
#ifdef MyTest
	freopen("Sakura.txt", "r", stdin);
#endif	
	int kase;
	cin >> kase;
	while(kase--){
		int n, d;
		cin >> n >> d;
		int ans = ceil(2.0 * sqrt(1.0 * d) - 1);
		if(ans <= n) puts("Yes");
		else puts("No");
	}
	return 0;
}
发布了281 篇原创文章 · 获赞 7 · 访问量 6716

猜你喜欢

转载自blog.csdn.net/qq_45228537/article/details/103994392
今日推荐