14 solutions

  • -2
    @ 2025-11-18 16:56:26

    解题报告

    撰写人: 潘梓莹

    题意分析

    如果n是质数,输出 "Yes";否则输出 "No"

    难度等级

    ★☆☆☆☆

    解题思路

    解题反思

    参考程序

    #include<bits/stdc++.h>
    using namespace std;
    int n;
    int main() {
        cin>>n;  
        bool zs=true;  
        for (int i=2;i*i<=n;i++) { 
            if(n%i==0) {  
                zs=false;  
                break;  
            }
        }
        if(zs) {
        cout<<"Yes"<<endl;
        } 
        else {
        cout<<"No"<<endl;
        }
        return 0;
    }
    
    

    Information

    ID
    602
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    51
    Accepted
    39
    Uploaded By