7 条题解

  • 4
    @ 2023-7-28 14:00:17
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        if (n==1) 
        {
            cout<<"N0";
            return 0;
        }
        for (int i=2;i<=sqrt(n);i++)
        {
            if (n%i==0)
            {
                cout<<"N0";
                return 0;
            }
        }
        cout<<"YE5";
        return 0;
    } 
    

    这个输出谁想出来的,我#¥#@&¥……%&……%&…………#¥%*&&……&*¥%#

    • 2
      @ 2023-7-22 16:45:17

      yasuo 但凡只要看了眼题,就80%不会错👀️

      #include <iostream>
      int main(){
          int q;std::cin>>q;
          if(q<2) {std::cout<<"N0";return 0;}
          for(int i=2;i*i<=q;i++)
              if(q%i==0){std::cout<<"N0";return 0;}
          std::cout<<"YE5";return 0;}
      
      • 1
        @ 2024-6-16 11:18:00
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
            int n,sum=0;
            cin>>n;
            for (int i=2;i<=n-1;i++)
            {
                if (n%i==0)
                {
                    sum+=1;
                }
            }
            if (n!=1 && sum==0)
            {   
                cout<<"YE5";   
            }
            else
            {
                cout<<"N0";
            }
            return 0;
        }
        好想知道这题为什么会是七星题。
        既然都看了,咱必须得点个赞吧。(●'◡'●)
        
        • 1
          @ 2023-6-23 8:13:58
          //这题目有点坑,是输出YE5或N0
          #include <iostream>
          using namespace std;
          int main()
          {
              int n;//创建一个储存那个数的变量
              cin>>n;
              int b=2;//看b是不是n的因数
              int z=0;//记录状态
              for (int i=1;i<=n-2;i++)
              {
                  if (n%b!=0)//如果b不是n的因数
                  {
                      b+=1;
                      z=0;//状态为零
                  }
                  else
                  {
                      z=1;//如果b是n的因数,状态为1
                      break;//别忘了结束循环
                  }
              }
              if (n==1 || n==2)//处理一下特殊情况
                  cout<<"N0";
              else if(z==0)//状态为0,就是质数
                  cout<<"YE5";
              else if(z==1)//状态为1,就是合数
                  cout<<"N0";
              return 0;
          }//这输出谁定的?站出来!保证不揍你!
          
          • 1
            @ 2023-6-23 0:01:06
            #include <iostream>
            using namespace std;
            
            int main() {
                int n;
                int a = 2;
                cin >> n;
                if (n <= 1) cout << "N0";
                else {
                    for (int i = 2;i < n;i++)
                        if (n % i == 0)
                            a += 1;
                        else a += 0;
                    if (a == 2)
                        cout << "YE5";
                    else cout << "N0";
                }
                return 0;
            }
            

            此题关键在于输出是N0而不是NO

            • 0
              @ 2024-5-26 17:21:05
              #include <iostream>
              using namespace std;
              int main()
              {
                  int n;
                  int flag = 1;
                  cin >> n;
                  for(int i =2;i <=n-1;i++)
                  {
                      if(n%i == 0)
                      {   flag = 0;
                          
                      }
                  }
              
                  
                  if(flag == 0||n == 1)
                      cout << "N0";
                  else if (flag == 1)
                      cout << "YE5";
                  return 0;
              }
              
              • 0
                @ 2023-7-15 11:26:49

                是ys5 和 n0啊!!! 谁出的题啊

                #include<iostream>
                #include<iomanip>
                #include<cmath>
                using namespace std;
                int main()
                {
                    int n,s=0;
                    cin>>n;
                    if (n==1)
                    {
                        cout<<"N0";
                        s+=1;
                    }
                    for (int i=2;i<n;i++)
                    {
                        if (n%i==0)
                        {
                            cout<<"N0";
                            s+=1;
                            break;///防止超时
                        }
                        if (i*i>n)
                        {
                            break;///防止超时*2
                        }
                    }
                    if (s==0)
                    {
                        cout<<"YE5";
                    }
                
                    return 0;
                }
                
                • 1

                信息

                ID
                173
                时间
                1000ms
                内存
                256MiB
                难度
                7
                标签
                递交数
                499
                已通过
                121
                上传者