AlbertMourato

Untitled

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