#include <iostream> #include <algorithm> using namespace std; bool is_prime(int x) { if (x < 2) return false; for (int i = 2; i <= x / i; i ++ ) if (x % i == 0) return false; return true; } int main() { int n; cin >> n; while (n -- ) { int x; cin >> x; if (is_prime(x)) puts("Yes"); else puts("No"); } return 0; }
AcWing 866. 试除法判定质数
猜你喜欢
转载自www.cnblogs.com/QingyuYYYYY/p/11854460.html
今日推荐
周排行