AlbertMourato

Untitled

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