A. Deadline (不等式、分块整除)
分块整除⌈x+d/(x+1)⌉=⌊x+(d+x)/(x+1)⌋=1+⌊x+(d−1)/(x+1)⌋
Code:
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;
int main()
{
int t;cin >> t;
while (t--)
{
int n, d;cin >> n >> d;
int f = 0;
for (int l = 1, r;l <= d;l=r+1)
{
r = d /(d/l);
if (l + (d-1)/ l <= n)
{
f = 1;break;
}
}
if (f)cout << "YES" << endl;
else cout << "NO" << endl;
}
}
不等式
参考博客https://www.cnblogs.com/pixel-Teee/p/12199936.html
只需判断2*sqrt(d)-1是否<=n即可