fork download
  1. // BỘI CHUNG NHỎ NHẤT
  2. // https://l...content-available-to-author-only...u.vn/problem/bcnnlcm
  3.  
  4. #include<bits/stdc++.h>
  5. #define MAX 1000000
  6. #define MOD 1000000007
  7. using namespace std;
  8.  
  9. int t, a, b, d[MAX], uoc[MAX];
  10.  
  11. void sanguoc(int n)
  12. {
  13. for(int i = 1; i <= n; i++)
  14. uoc[i] = 0;
  15. for(int i = 2; i * i <= n; i++)
  16. if(uoc[i] == 0)
  17. for(int j = i * i; j <= n; j += i)
  18. if(uoc[j] == 0) uoc[j] = i;
  19. for(int i = 1; i <= n; i++)
  20. if(uoc[i] == 0) uoc[i] = i;
  21. }
  22.  
  23. void phantich(int n)
  24. {
  25. while(n > 1)
  26. {
  27. int x = uoc[n];
  28. int dem = 0;
  29. while(n % x == 0)
  30. {
  31. n /= x;
  32. dem++;
  33. }
  34. d[x] += dem;
  35. }
  36. if(n > 1) d[n]++;
  37. }
  38.  
  39. int main()
  40. {
  41. ios_base::sync_with_stdio(0);
  42. cin.tie(0); cout.tie(0);
  43. #define name "cau4"
  44. if(fopen(name".inp", "r"))
  45. {
  46. freopen(name".inp", "r", stdin);
  47. freopen(name".out", "w", stdout);
  48. }
  49. sanguoc(MAX);
  50. cin >> t;
  51. while(t--)
  52. {
  53. cin >> a >> b;
  54. long long ans = 1;
  55. for(int i = 1; i <= b; i++)
  56. d[i] = 0;
  57. for(int i = a; i <= b; i++)
  58. phantich(i);
  59. for(int i = 2; i <= b; i++)
  60. if(d[i] > 0)
  61. ans = ans * (2 * d[i] + 1) % MOD;
  62. cout << ans << '\n';
  63. }
  64.  
  65. }
  66.  
Success #stdin #stdout 0.01s 9280KB
stdin
Standard input is empty
stdout
Standard output is empty