Why its not working (T-primes) HERE IS THE LINK TO QUESTION — https://codeforces.com/problemset/problem/230/B

Revision en1, by ABhinav2003, 2020-04-26 14:25:06

//THIS IS MY SOLUTION

include<bits/stdc++.h>

using namespace std;

bool prime(long long int a) { bool c= true; for(int i = 2;i<=sqrt(a);i++) { if(a%i == 0) { c = false; break; } } if(c == true ) return true; else return false;

}

bool T_PRIME(long long int a) { float test = sqrt(a) ; int test1 = floor(sqrt(a));

if(test - test1 == 0)
{
    if(prime(sqrt(a)) == true)
       return true;
    else
       return false;
}
else
    return false;

}

int main() { int t; cin>>t; vector a; for(int i = 0;i<t;i++) { int k; cin>>k; a.push_back(k);

}

for(auto i : a)
{
    if(T_PRIME(i) == true)
       cout<<"YES"<<"\n";
    else
       cout<<"NO"<<"\n";
}

}

Tags t-primes, #solution, #help, #error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ABhinav2003 2020-04-26 14:25:06 864 Initial revision (published)