9 条题解

  • 2
    @ 2026-10-7 20:48:07
    /*****************************************
    备注: 质数的判断方式
    
    n  = a * b 
    
      a <= sqrt(n) <= b
    
    ******************************************/
    #include <math.h>
    #include <stdio.h>
    #include <iostream>
    #include <string.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin >> n;
    	bool flag = 1;
    	for(int i = 2  ; i * i <= n ; i++)
    	{
    		if(n % i == 0)
    		{
    			flag = 0;
    			break;
    		}
    	}
    	if(flag == 1)
    	{
    		cout << "YES";
    	}
    	else 
    	{
    		cout << "NO\n";
    	}
    
    }
    

    信息

    ID
    963
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    506
    已通过
    211
    上传者