7 条题解

  • 1
    @ 2024-4-9 13:31:24
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int j,q,k,a;
    	cin>>j;
    	for(int i=2;i<j;i++)
    	if(j%i==0)
    	{
    		cout<<"no";
    		return 0;
    	}
    	cout<<"yes";
    	return 0;
    }
    
  • 0
    @ 2025-1-1 13:28:08

    #include<bits/stdc++.h> using namespace std; bool sushu(int a) { if(a1) return false; for(int i=2;i*i<=a;i++) { if(a%i0) return false; } return true; } int main() { int r; cin>>r; if(sushu(r)) { cout<<"yes"; } else { cout<<"no"; } return 0; }

    • 0
      @ 2024-11-25 13:01:14

      #include<bits/stdc++.h> using namespace std; bool sushu(int n) { if(n1)return false; for(int i=2;i*i<=n;i++) { if(n%i0) return false; } return true; } int main() { int n; cin>>n; if(sushu(n)) { cout<<"yes"; } else cout<<"no"; return 0; }

      • 0
        @ 2024-11-25 13:00:29

        #include<bits/stdc++.h> using namespace std; bool sushu(int n) { if(n1)return false; //1²»ÊÇËØÊý for(int i=2;i*i<=n;i++)//¼ìÑé1µ½x¿ª¸ùºÅ¼´¿É { if(n%i0) return false;//±»iÈ¡ÓàΪ0£¬²»ÊÇËØÊý } return true; }//¶¨ÒåËØÊýº¯Êý int main() { int n; cin>>n; if(sushu(n)) { cout<<"yes"; } else cout<<"no"; return 0; }

        • 0
          @ 2024-11-19 22:45:55
          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
          	int n,i,d;
          	cin>>n;
          	if(n>=1&&n<=100000)
          	{
          		for(i=1;i*i<=n;i++)
          		{
          			if(n%i==0&&i!=1)
          			{
          				d=0;
          				break;
          			}
          			if(n%i!=0)
          			{
          				d=1;
          			}
          		}
          		if(d==1&&i!=1)
          		{
          			cout<<"yes"<<endl;
          		}
          		else if(d==0)
          		{
          			cout<<"no"<<endl;
          		}
          	}
          	return 0;
          }
          
          • 0

            利用方根的方法我这里总是过不了 所以我选择无脑硬取余

            • -2
              @ 2024-11-25 16:38:38
              #include<bits/stdc++.h>
              using namespace std;
              int sushu(int a)
              {
              	int b;
              	for(int i=2;i*i<=a;i++)
              	{
              		if(a%i==0)
              		{
              			b=1;
              			break;
              		}
              		else
              		if(a%i!=0)
              		{
              			b=0;
              		}
              	}
              	if(b==0&&a!=1)
              	{
              		return 1;
              	}
              	else
              	{
              		return 0;
              	}
              }
              int main()
              {
              	int n;
              	cin>>n;
              	if(sushu(n)==1)
              	{
              		cout<<"yes";
              	}
              	else
              	if(sushu(n)==0)
              	{
              		cout<<"no";
              	}
              }
              
              • 1

              信息

              ID
              91
              时间
              1000ms
              内存
              256MiB
              难度
              4
              标签
              递交数
              75
              已通过
              32
              上传者