T-Prime Problem

Sir Plz Check The code . It is satisfying 2 Test Cases and remaining 3 Test Cases having Wrong answer.
#include<bits/stdc++.h>
using namespace std;

bool isPrime(int x){
if(x==1){
return false;
}
for(int i=2;i*i<=x;i++){
if(x%2==0){
return false;
}
}
return true;

}

int main(){
int t;
cin>>t;
while(t–){
int n,y;
cin>>n;

float x = sqrt(n);

y = x*10;

if(y%10==0){
    if(isPrime(x))
        cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
}else
    cout<<"NO"<<endl;

}
return 0;
}

As the square of prime is T Prime . So i calculated the square root of input and then checked it is prime or not .

If this approch is wrong then plz guide me in the code

#include #include using namespace std; int main(){ int t; cin>>t; while(t–){ long n; cin>>n; vectorv1; vector::iterator it1; for(long i=0;i<n;i++){ long x; cin>>x; v1.push_back(x); } long temp = 1; for(it1 =v1.begin();it1!=v1.end();it1++){ temp*=*it1; } long cnt = 1; for(long i=2;i<=temp;i++){ if(temp%i==0){ cnt+=1; } } cout<<cnt<<endl; } return 0; }

hint video still unable to understand

You shall use floor and ceil , avoid using sqrt function.
Rest Logic is fine.

So sir in your given code we clearly ignored the first 3 number that are 1,2,3 and then we used that sqrt concept to get required ans.