fork(1) download
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. const int N = 5e6 + 5;
  5.  
  6. int h[N];
  7. vector < int > spf, primes;
  8.  
  9. void RunLinearSieve() {
  10. int n = N;
  11. spf.assign(n + 1, 0);
  12. for(int i = 2; i < n; ++i) {
  13. if(!spf[i]) {
  14. spf[i] = i;
  15. primes.push_back(i);
  16. }
  17. for(int x : primes) {
  18. int calc = i * x;
  19. if(x > spf[i] || calc > n) {
  20. break;
  21. }
  22. spf[calc] = x;
  23. }
  24. }
  25. primes.clear();
  26. for (int j = 2; j < N; ++j) {
  27. int let = j, cnt(0);
  28. while (let != 1) {
  29. let /= spf[let];
  30. ++cnt;
  31. }
  32. h[j] = cnt + h[j-1];
  33. }
  34. }
  35. inline void solve() {
  36. int a, b;
  37. cin >> a >> b;
  38. if (a == b) {
  39. cout << "0\n";
  40. return;
  41. }
  42. int t = a - b;
  43. cout << h[a] - h[a-t] << '\n';
  44. }
  45.  
  46. signed main() {
  47. ios_base::sync_with_stdio(0);
  48. cin.tie(NULL);
  49. cout.tie(NULL);
  50. int t = 1;
  51. RunLinearSieve();
  52. cin >> t; while(t--)
  53. solve();
  54. return 0;
  55. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:1: error: stray ‘\302’ in program
  
 ^
prog.cpp:3:2: error: stray ‘\240’ in program
  
  ^
prog.cpp:5:1: error: stray ‘\302’ in program
  
 ^
prog.cpp:5:2: error: stray ‘\240’ in program
  
  ^
prog.cpp:8:1: error: stray ‘\302’ in program
  
 ^
prog.cpp:8:2: error: stray ‘\240’ in program
  
  ^
prog.cpp:45:1: error: stray ‘\302’ in program
  
 ^
prog.cpp:45:2: error: stray ‘\240’ in program
  
  ^
stdout
Standard output is empty