52 条题解

  • 26
    @ 2022-8-10 21:42:43

    兄弟们,看过以前我发题解的童鞋们应该知道,这种题目,em,一句话用 if - if - if - if 即可,太简单,或者用循环,但是!这里的标题是……


    分支问题!

    好吧,来吧,上代码 (不用顶了……过于简单)

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        if (n % 2 == 0) cout << 2 << endl;
        if (n % 3 == 0) cout << 3 << endl;
        if (n % 5 == 0) cout << 5 << endl;
        if (n % 7 == 0) cout << 7 << endl;
        return 0;
    }
    
    • 9
      @ 2022-7-22 9:31:09

      这道题很简单,只需要if语句就能完成。


      直接上核心代码!

      if(n%2==0) cout<<"2\n";
      if(n%3==0) cout<<"3\n";
      if(n%5==0) cout<<"5\n";
      if(n%7==0) cout<<"7\n";
      

      注意,转义符号\n也能换行。 可以了解一下转义符。

      转义符号 含义
      \n 换行
      \t 横向跳格
      \ddd 1到3位八进制数字
      \r 回车
      \xhh 1到2位十六进制数字

      就这么简单!

      • @ 2022-8-10 21:35:15

        厉害啊!顶!以后你们学 window 系统的时候还有更多歪门邪道等着你们探索~👀️

      • @ 2022-9-4 10:36:21

        真厉害!!!!!!!!👍 👍

      • @ 2023-7-9 15:44:12

        试了一下,好像不行。

      • @ 2023-8-24 20:13:56

        😄 👍 👍 🎉️ 一个字绝

      • @ 2023-11-12 15:39:12

        @ 绝你丫的😄,应该叫

      • @ 2024-2-5 15:18:36

        66666666666666666666666666666666666666666666666666666666666666666666666666666

      • @ 2024-3-23 17:29:02

        12级大佬都叫爹

    • 8
      @ 2023-8-23 11:40:42
      #include <iostream>
      using namespace std;
      int main()
      {
          int n;
          cin >> n;
          if (n%2==0)
          {
              cout << 2 << endl;
          }
          if (n%3==0)
          {
              cout << 3 << endl;
          }
          if (n%5==0)
          {
              cout << 5 << endl;
          }
          if (n%7==0)
          {
              cout << 7 << endl;
          }
          return 0;
      }
      

      点个赞吧! 已AC✔ 可复制❄

    • 1
      @ 2024-5-26 17:25:23

      这是我第一次发题解,有做的不好的地方请告诉我谢谢! 接下来我们分析一下这题—— 1.这题题目已经告诉我们了!我们要判断是不是这几个数字的倍数,所以根据入门级的难度(肯定很**),判断要几个对吧! 2.没有2(

      相信没有人喜欢上面的一通分析拔,代码来啦!(没有反抄袭,但是尽量别复制,作者会伤心qwq)

      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin >> n;
          if (n % 2 == 0) cout << 2 << endl;
          if (n % 3 == 0) cout << 3 << endl;
          if (n % 5 == 0) cout << 5 << endl;
          if (n % 7 == 0) cout << 7 << endl;    
          return 0;
      }
      

      这道题很简单!如果有我在luogu上团队的成员不会做,哼哼(我的规矩你们都知道(团队成员))

      • 0
        @ 2024-6-10 18:09:40
        #include <iostream>
        using namespace std;
        int main()
        {
            int n;
            cin >> n;
            if (n%2==0)
            {
                cout << 2 << endl;
            }
            if (n%3==0)
            {
                cout << 3 << endl;
            }
            if (n%5==0)
            {
                cout << 5 << endl;
            }
            if (n%7==0)
            {
                cout << 7 << endl;
            }
            return 0;
        }
        
        • 0
          @ 2024-2-23 9:49:23

          代码来了! `

          #include <bits/stdc++.h>
          using namespace std;
          int main()
          {
              int n;
              cin>>n;
              if(n%2==0)
              {
                  cout<<"2"<<endl;
              }
              if(n%3==0)
              {
                  cout<<"3"<<endl;
              }
              if(n%5==0)
              {
                  cout<<"5"<<endl;
              }
              if(n%7==0)
              {
                  cout<<"7"<<endl;
              }
              return 0;
          }
          
          • 0
            @ 2024-2-17 14:41:35
            1. 额(⊙﹏⊙),这题就一句话,if-if-if-if,应该没人不懂吧😕 ,但一定不要和else if弄混了,当然啦,for循环也是可以滴(不过我重点讲if语句)🎉️ (AC哒,大佬们放心) ``` #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n%20) { cout<<2<<endl; } if(n%30) { cout<<3<<endl; } if(n%50) { cout<<5<<endl; } if(n%70) { cout<<7<<endl; } return 0; } 制作不易,点个赞呗👍 !!! b( ̄▽ ̄)d
            
            
          • 0
            @ 2024-1-18 20:24:29
            using namespace std;
            int main()
            {
                int n;
                cin >> n;
                if (n % 2 == 0)
                {
                    cout << 2 << endl;
                }
                if (n % 3 == 0)
                {
                    cout << 3 << endl;
                }
                if (n % 5 == 0)
                {
                    cout << 5 << endl;
                }
                if (n % 7 == 0)
                {
                    cout << 7 << endl;
                }
                return 0;
            }
            
            • 0
              @ 2023-12-9 10:47:48
              #include <bits/stdc++.h> 
              using namespace std;
              int main()
              {
                  int q;
                  cin>>q;
                  if(q%2==0) {
                      cout<<2<<endl;
                  }
                  if(q%3==0){
                      cout<<3<<endl;
                  }
                  if(q%5==0) {
                      cout<<5<<endl;
                  }
                  if(q%7==0) {
                      cout<<7<<endl;
                  }
                  return 0;
              }
              
              • 0
                @ 2023-12-5 19:36:47
                #include <iostream>
                using namespace std;
                int main()
                {
                    int a;
                    cin >> a;
                    if (a % 2 == 0)
                    {
                        cout << 2 << endl;
                    }
                    if (a % 3 == 0)
                    {
                        cout << 3 << endl;
                    }
                    if (a % 5 == 0)
                    {
                        cout << 5 << endl;
                    }
                    if (a % 7 == 0)
                    {
                        cout << 7 << endl;
                    }
                    return 0;
                }
                
                • 0
                  @ 2023-11-26 11:35:29
                  #include <bits/stdc++.h>
                  using namespace std;
                  int main()
                  {
                      int n;
                      cin >> n;
                      if (n % 2 == 0) cout << 2 << endl;
                      if (n % 3 == 0) cout << 3 << endl;
                      if (n % 5 == 0) cout << 5 << endl;
                      if (n % 7 == 0) cout << 7 << endl;
                      return 0;
                  }
                  
                  • 0
                    @ 2023-11-19 19:44:55
                    #include <bits/stdc++.h> 
                    using namespace std;
                    int main()
                    {
                     	int n;
                     	int a[999];
                     	a[1]=2,a[2]=3,a[3]=5,a[4]=7;
                     	cin>>n;
                     	for(int i=1;i<=4;i++){
                    	 	if(n%a[i]==0){
                    		 	cout<<a[i]<<endl;
                    		 }
                    	 }
                        return 0;
                    }
                    
                    • 0
                      @ 2023-9-23 17:35:55

                      这道题可以运用等差数列的知识 2除外\n 你为神马连这么简单的题都要看题解!

                      #include <iostream>
                      using namespace std;
                      int main(){
                          int a;cin>>a;
                          if (a%2==0){
                              cout<<2<<endl;
                          }
                          for (int i=3;i<=7;i+=2){
                              if (a%i==0){
                              cout<<i<<endl;
                          }
                          }
                      }
                      

                      抱歉,这是上道题的 这个才是

                      #include <iostream>
                      using namespace std;
                      int main(){
                          int a;cin>>a;
                          if (a%2==0){
                              cout<<2<<endl;
                          }
                          for (int i=3;i<=7;i+=2){
                              if (a%i==0){
                              cout<<i<<endl;
                          }
                          }
                      }
                      

                      不对呀,就是啊!

                      • 0
                        @ 2023-8-18 11:23:41

                        简简单单,上代码!

                        #include <bits/stdc++.h>
                        using namespace std;
                        int main()
                        {
                            int n;
                            cin >> n;
                            if (n % 2 == 0)
                            {
                                cout << 2 << endl;
                            }
                            if (n % 3 == 0)
                            {
                                cout << 3 << endl;
                            }
                            if (n % 5 == 0)
                            {
                                cout << 5 << endl;
                            }
                            if (n % 7 == 0)
                            {
                                cout << 7;
                            }
                            return 0;
                        }
                        
                        • 0
                          @ 2023-8-15 12:09:21
                          #include <
                          

                          bits/stdc++.h

                          using namespace std;
                          int main()
                          {
                              int n;
                              cin >> n;
                              if (n % 2 == 0)
                              {
                                  cout << 2 << endl;
                              }
                              if (n % 3 == 0)
                              {
                                  cout << 3 << endl;
                              }
                              if (n % 5 == 0)
                              {
                                  cout << 5 << endl;
                              }
                              if (n % 7 == 0)
                              {
                                  cout << 7 << endl;
                              }
                              return 0;
                          }
                          //上一关把我快弄疯了,于是开始用万能了,AC过了,请放心使用不要❤️ 
                          
                          • 0
                            @ 2023-8-14 21:49:14

                            #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n%20) { cout<<"2"<<endl; } if(n%30) { cout<<"3"<<endl; } if(n%50) { cout<<"5"<<endl; } if(n%70) { cout<<"7"<<endl; } return 0; }

                            • 0
                              @ 2023-8-14 15:10:15

                              这题,,嗯,,非常简单好吧, 直接上代码叭——

                              #include <iostream>
                              using namespace std;
                              int main()
                              {
                                  int n;
                                  cin >> n;
                                  if (n % 2 == 0)
                                  {
                                      cout << 2 << endl;
                                  }
                                  if (n % 3 == 0)
                                  {
                                      cout << 3 << endl;
                                  }
                                  if (n % 5 == 0)
                                  {
                                      cout << 5 << endl;
                                  }
                                  if (n % 7 == 0)
                                  {
                                      cout << 7 << endl;
                                  }
                                  return 0;
                              }
                              
                              • 0
                                @ 2023-8-9 9:56:31
                                #include <bits/stdc++.h>
                                using namespace std;
                                int main()
                                {
                                    int n;
                                    cin >> n;
                                    if (n % 2 == 0)
                                    {
                                     cout << 2 << endl;   
                                    } 
                                    if (n % 3 == 0)
                                    {
                                     cout << 3 << endl;
                                    }
                                    if (n % 5 == 0)
                                    {
                                     cout << 5 << endl;
                                    }
                                    if (n % 7 == 0)
                                    {
                                         cout << 7 << endl;
                                    }
                                    return 0;
                                

                                我有的会在 讨论 里,请大家多看讨论,谢谢

                                • 0
                                  @ 2023-8-3 18:29:06

                                  这题用if分支结构就好啦

                                  #include <bits/stdc++.h>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin >> n;
                                      if (n % 2 == 0) cout << 2 << endl;
                                      if (n % 3 == 0) cout << 3 << endl;
                                      if (n % 5 == 0) cout << 5 << endl;
                                      if (n % 7 == 0) cout << 7 << endl;
                                      return 0;
                                  }
                                  
                                  • 0
                                    @ 2023-8-2 21:43:21

                                    遍历判断

                                    #include <iostream>
                                    using namespace std;
                                    int main()
                                    {
                                        int n,a[]={2,3,5,7};
                                        cin>>n;
                                        for (auto i : a)
                                        {
                                            if (n%i==0) cout<<i<<endl;
                                        }
                                        return 0;
                                    }
                                    

                                    【入门】请问一个整数n能够被2、3、5、7中哪些数整除

                                    信息

                                    ID
                                    296
                                    时间
                                    1000ms
                                    内存
                                    16MiB
                                    难度
                                    2
                                    标签
                                    递交数
                                    3110
                                    已通过
                                    1838
                                    上传者