Блог пользователя ABhinav2003

Автор ABhinav2003, история, 4 года назад, По-английски

//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";
}

}

  • Проголосовать: нравится
  • -28
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +22 Проголосовать: не нравится

Codeforces community isn't here to debug your code.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Use Pastebin(https://pastebin.ubuntu.com/) to post your code with proper indentation.

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Your mistake is simple and I bet you didn't properly search for it.