Educational Codeforces Round 80 (Rated for Div. 2) A. Deadline
https://codeforces.com/contest/1288/problem/A
思路:
⌈
d
x
+
1
⌉
=
⌊
d
+
x
x
+
1
⌋
=
1
+
⌊
d
−
1
x
+
1
⌋
\lceil \frac{d}{x+1} \rceil=\lfloor\frac{d+x}{x+1}\rfloor=1+\lfloor\frac{d-1}{x+1}\rfloor
⌈x+1d⌉=⌊x+1d+x⌋=1+⌊x+1d−1⌋,直接数论分块求出最小值即可
其他解法见:https://blog.csdn.net/xing_mo/article/details/103982101
#include<bits/stdc++.h>
using namespace std;
int n,d;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&d);
--d;
int minn = 1e9+5;
if(d == 0)
minn = 1;
for(int l = 1,r;l <= d;l = r+1)
{
r = d/(d/l);
minn = min(minn,l+d/l);
}
if(minn <= n)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}