fork(1) download
  1. /// Author : Nguyễn Thái Sơn - K18 - KHMT - UIT
  2. /// Training ICPC 2024
  3.  
  4. #include<bits/stdc++.h>
  5.  
  6. /// #pragma GCC optimize("O3,unroll-loops")
  7. /// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
  8.  
  9. #define fi first
  10. #define se second
  11. #define TASK "BAI4"
  12. #define pb push_back
  13. #define EL cout << endl
  14. #define Ti20_ntson int main()
  15. #define in(x) cout << x << endl
  16. #define all(x) (x).begin(),(x).end()
  17. #define getbit(x, i) (((x) >> (i)) & 1)
  18. #define cntbit(x) __builtin_popcount(x)
  19. #define FOR(i,l,r) for (int i = l; i <= r; i++)
  20. #define FORD(i,l,r) for (int i = l; i >= r; i--)
  21. #define Debug(a,n) for (int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl
  22.  
  23. using namespace std;
  24.  
  25. typedef long long ll;
  26. typedef vector<int> vi;
  27. typedef pair<int,int> vii;
  28. typedef unsigned long long ull;
  29. typedef vector<vector<int>> vvi;
  30. int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
  31.  
  32. const int N = 105;
  33. const int oo = INT_MAX;
  34. const int mod = 1e9 + 7;
  35. const int d4x[4] = {-1, 0, 1, 0} , d4y[4] = {0, 1, 0, -1};
  36. const int d8x[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8y[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  37.  
  38. ll l, r;
  39. int pre[N];
  40.  
  41. bool Check(int val) {
  42. if (val < 2) return 0;
  43. for (int i = 2; i * i <= val; i++)
  44. if (val % i == 0) return false;
  45. return true;
  46. }
  47.  
  48. inline void Read_Input() {
  49. FOR(i, 3, 100) {
  50. pre[i] = Check(i);
  51. pre[i] += pre[i - 1];
  52. }
  53. cin >> l >> r;
  54. }
  55.  
  56. inline void Solve() {
  57. ll Ans = 0;
  58. for (ll i = 2; i * i <= r; i++) {
  59. if (Check(i) == 0) continue;
  60. int cntL = 1, cntR = 1;
  61. ll L = i, R = i;
  62. while (L < l) L = L * i, cntL++;
  63. while (R <= r) R = R * i, cntR++;
  64. Ans += pre[cntR] - pre[cntL];
  65. }
  66. cout << Ans;
  67. }
  68.  
  69. Ti20_ntson {
  70. freopen(TASK".INP","r",stdin);
  71. freopen(TASK".OUT","w",stdout);
  72. ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  73. int T = 1;
  74. while (T -- ) {
  75. Read_Input();
  76. Solve();
  77. }
  78. }
  79.  
  80.  
  81.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty