zoukankan      html  css  js  c++  java
  • AcWing 866. 试除法判定质数

    #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;
    }
  • 相关阅读:
    126
    125
    124
    123
    122
    121
    120
    119
    洛谷 P5407 【[THUPC2019]历史行程】
    济南清北学堂七日游
  • 原文地址:https://www.cnblogs.com/QingyuYYYYY/p/11854460.html
Copyright © 2011-2022 走看看