Advertisement
halexandru11

c

Feb 12th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. #include <algorithm>
  2. #include <array>
  3. #include <bitset>
  4. #include <cassert>
  5. #include <climits>
  6. #include <cmath>
  7. #include <complex>
  8. #include <cstdio>
  9. #include <cstdlib>
  10. #include <cstring>
  11. #include <fstream>
  12. #include <functional>
  13. #include <iomanip>
  14. #include <iostream>
  15. #include <map>
  16. #include <memory>
  17. #include <numeric>
  18. #include <queue>
  19. #include <random>
  20. #include <set>
  21. #include <stack>
  22. #include <string>
  23. #include <unordered_set>
  24. #include <unordered_map>
  25. #include <vector>
  26. using namespace std;
  27.  
  28. /// START Errichto's debug
  29. #define sim template < class c
  30. #define ris return * this
  31. #define dor > debug & operator <<
  32. #define eni(x) sim > typename \
  33. enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
  34. sim > struct rge { c b, e; };
  35. sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
  36. sim > auto dud(c* x) -> decltype(cerr << *x, 0);
  37. sim > char dud(...);
  38. struct debug {
  39. #ifdef LOCAL
  40. ~debug() { cerr << endl; }
  41. eni(!=) cerr << boolalpha << i; ris; }
  42. eni(==) ris << range(begin(i), end(i)); }
  43. sim, class b dor(pair < b, c > d) {
  44. ris << "(" << d.first << ", " << d.second << ")";
  45. }
  46. sim dor(rge<c> d) {
  47. *this << "[";
  48. for (auto it = d.b; it != d.e; ++it)
  49. *this << ", " + 2 * (it == d.b) << *it;
  50. ris << "]";
  51. }
  52. #else
  53. sim dor(const c&) { ris; }
  54. #endif
  55. };
  56. #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  57. // debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
  58. /// END Errichto's debug
  59.  
  60. #define ff first
  61. #define ss second
  62. #define eb emplace_back
  63. #define mp make_pair
  64. #define pb push_back
  65. #define ppb pop_back
  66. #define all(a) a.begin(), a.end()
  67. #define rall(a) a.rbegin(), a.rend()
  68. #define f0(i, n) for(auto i = 0; i < n; ++i)
  69. #define fo(i, k, n) for(auto i = k; i < n; ++i)
  70. #define foo(i, a, b, k) for(auto i = a; i < b; i += k)
  71. #define rf0(n, i) for(auto i = n-1; ~i; --i)
  72. #define rfo(n, k, i) for(auto i = n-1; i >= k; --i)
  73. #define rfoo(b, a, k, i) for(auto i = b; i > a; i -= k)
  74. #define Im_speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  75.  
  76. typedef long double ld;
  77. typedef uint32_t uint;
  78. typedef int64_t ll;
  79. typedef uint64_t ull;
  80.  
  81. //ifstream fin("date.in");
  82. //ofstream fout("date.out");
  83.  
  84. const int nax = 1e5 + 3;
  85. const int mod = 1e9 + 7;
  86. const int inf = 1e9 + 7;
  87. const ll infll = 1e18 + 7;
  88. const ld PI = 3.1415926535897932384626433832795;
  89.  
  90. void solve() {
  91. ll x, y;
  92. cin >> x >> y;
  93.  
  94. ll ans = 0;
  95. fo(r, 1, y) {
  96. ll z = (r+1)*r + r;
  97. if(z > x) {
  98. break;
  99. }
  100. ans += min((x - z)/r, y-1-r) + 1;
  101. }
  102. cout << ans << "\n";
  103. }
  104.  
  105. int main() {
  106. // clock_t _clock = clock();
  107. Im_speed;
  108. cout << fixed << setprecision(12);
  109.  
  110. int t = 1;
  111. cin >> t;
  112. while(t--) {
  113. solve();
  114. }
  115.  
  116. // cout << ((((double) clock()) - ((double)_clock)) / ((double) CLK_TCK));
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement