fork download
  1. //Zang Vũ
  2. #include <iostream>
  3. #include <vector>
  4. #include <math.h>
  5. #include <bitset>
  6. #include <cctype>
  7. #include <string>
  8. #include <algorithm>
  9. #include <unordered_map>
  10. #include <unordered_set>
  11.  
  12. #pragma GCC optimize("O3,unroll-loops")
  13. #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
  14.  
  15. using namespace std;
  16.  
  17. #define v vector
  18. #define umap unordered_map
  19. #define uset unordered_set
  20. #define ll long long
  21. #define up upper_bound
  22. #define low lower_bound
  23. #define bin binary_search
  24. #define f(array) (array).begin(), (array).end()
  25. #define b(array) (array).rbegin(), (array).rend()
  26.  
  27. inline ll count(ll left, ll right, ll target) {
  28. ll start = left / target, end = right / target;
  29. if (left % target != 0) start++;
  30. return end - start + 1;
  31. }
  32.  
  33. int main() {
  34. cin.tie(nullptr), cout.tie(nullptr)
  35. -> ios_base::sync_with_stdio(false);
  36.  
  37. #ifndef ONLINE_JUDGE
  38. freopen ("main.inp", "r", stdin);
  39. freopen ("main.out", "w", stdout);
  40. #endif
  41.  
  42. int queries;
  43. cin >> queries;
  44. while (queries--) {
  45. ll left, right;
  46. cin >> left >> right;
  47. ll result = count(left, right, 4) + count(left, right, 7) + count(left, right, 11)
  48. - count(left, right, 28) - count(left, right, 44) - count(left, right, 77)
  49. + count(left, right, 308);
  50. cout << result << endl;
  51. }
  52. }
  53.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty