fork download
  1. #include <bits/stdc++.h>
  2. #include <string.h>
  3. using namespace std;
  4. #define ll long long
  5.  
  6. int main() {
  7. int t;
  8. cin>>t;
  9. while(t--){
  10. ll r,l;cin>>l>>r;
  11. ll n=sqrt(2*(r-l));
  12. while(n && n*(n+1)>2*(r-l)){n--;}
  13. cout<<n+1<<endl;
  14.  
  15.  
  16.  
  17. }return 0;
  18. }
Success #stdin #stdout 0.01s 5280KB
stdin
5
1 2
1 5
2 2
10 20
1 1000000000
stdout
2
3
1
5
44721