Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int prime(int n){
- int raiz = sqrt(n)+1;
- for(int i = 2; i<raiz; i++){
- if(n%i==0){
- return 0;
- break;
- }
- }
- return 1;
- }
- int main() {
- int t;
- ll a, b, s = 0;
- cin>>t;
- double aux;
- while(t>0){
- cin>>a>>b;
- s = 0;
- if(a==1) a++;
- for(int i= a;i<=b;i++){
- aux = sqrt(i);
- if(pow(aux, 2)==i){
- if(prime(aux)){
- s++;
- }
- }
- }
- cout<<s<<"\n";
- t--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment