fork download
  1. #include <bits/stdc++.h>
  2. #define FIO ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
  3. #define pi acos(-1)
  4. #define lli long long int
  5. #define max 10000009
  6. using namespace std;
  7. int prime[max];
  8.  
  9. void seive()
  10. {
  11. prime[0] = 1;
  12. prime[1] = 1;
  13. int i,j,root=sqrt(max+1);
  14. for ( i = 4; i < max; i += 2)
  15. prime[i] = 1;
  16. for ( i = 3; i < max; i+=2)
  17. {
  18. if (!prime[i] && i <= root)
  19. {
  20. for ( j = i*i; j < max; j += 2*i)
  21. {
  22. prime[j] = 1;
  23. }
  24. }
  25. }
  26. return;
  27. }
  28. int main()
  29. {
  30. FIO
  31. seive();
  32. lli i,n,t,j,q,x,y;
  33. cin >> t;
  34. int arr[t+2];
  35. for ( i = 0; i < t; i++)
  36. cin >> arr[i];
  37. cin >> q;
  38.  
  39. while (q--)
  40. {
  41. int cc = 0;
  42. cin >> n >> x >> y;
  43. if(n == 1)
  44. {
  45. for ( i = x-1; i < y; i++)
  46. {
  47. if(prime[arr[i]] == 0) cc ++;
  48. }
  49. cout << cc << endl;
  50. }
  51. else {
  52. arr[x-1] = y;
  53. }
  54. }
  55.  
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0.09s 42644KB
stdin
10 
12 9 29 14 9 76 7 6 8 10
5
1 1 4
2 4 29
1 1 4
2 1 29
1 1 4
stdout
1
2
3