AlbertMourato

Untitled

Dec 6th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. ll primo[100000];
  5. int main() {
  6.     //freopen("out.txt", "w", stdout);
  7.     //fazendo crivo
  8.     for(ll i = 2;i<=100000;i++){
  9.         primo[i]=1;
  10.     }
  11.     for(ll i = 2;i<=100000;i++){
  12.         if(primo[i]){
  13.             for(int j = 2*i;j<=100000;j+=i){
  14.                 primo[j] = 0;
  15.             }
  16.         }
  17.     }
  18.     int t;
  19.     ll a, b, s = 0;
  20.     cin>>t;
  21.     double aux;
  22.     ll aux2=0;
  23.     while(t>0){
  24.         cin>>a>>b;
  25.         s = 0;
  26.         for(int i= a;i<=b;i++){
  27.             aux = sqrt(i);
  28.             if(pow(aux, 2)==i){
  29.                 aux2 = (ll)aux;
  30.                 if(primo[aux2]){
  31.                     s++;
  32.                 }
  33.             }
  34.         }
  35.         cout<<s<<"\n";
  36.         t--;
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment