83 条题解

  • 1
    @ 2022-12-24 21:57:36

    基础版

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, b;
        cin >> a >> b;
        cout << (a + b - 1) - (abs(a - b) + 1) + 1;
        return 0;
    }
    

    提高版

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long a, b, t;
        cin >> a >> b;
        if (a < b)
        {
            t = a;
            a = b;
            b = t;
        }
        t = a + b - 1 - (a - b);
        cout << t << endl;
        return 0;
    }
    
  • 1
    @ 2022-11-2 13:57:27

    小号题解

    #include <iostream>
    using namespace std;
    int main()
    {
        int a,b,min=0,max=0;
        cin >> a >> b;
        if(a>b)
        {
            max=a;
            min=b;
        }
        else
        {
            max=b;
            min=a;
        }
        cout << a+b-1-max+min;
    }
    
    • 1
      @ 2022-10-6 15:32:02

      这道题啊,非常简单,话不多说,上代码!用if...else if...else语句

      #include<iostream>
      using namespace std;
      int main()
      {
          long long a , b;
          cin >> a >> b;
          if (a > b )
          {
               cout << a + b - (a - b ) - 1;
          }
          else if (a < b)
          { 
               cout << a + b - ( b - a ) - 1;
          }
          else
          {
               cout << a + b - 1;
          }
          return 0;
      }
      
    • 0
      @ 2024-6-1 18:37:41
      #最简单的枚举算法
      #include <iostream>
      using namespace std;
      int main()
      {
          int n=0,a,b;
          cin>>a>>b;
          if (a>b)   #a>b的情况
          {
              for (int i=a-b+1;i<b+a;i++)
              {
                  n++;
              }
          }
          else   #b>a的情况
          {
              for (int i=b-a+1;i<b+a;i++)
              {
                  n++;
              }
          }
          cout<<n;
      }
      

      #注意要开(o2)优化,否则时间会超时

      • 0
        @ 2024-5-22 21:36:06

        a = int(input()) b = int(input()) c = 1 if b > a: print(a - b) else: print(b - a)

        学python的来看一下 到底哪错了???

        • 0
          @ 2024-4-9 22:33:33

          其实他不难的,加油,我相信你 #include <bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; if (a>b) { cout<<a+b-(a-b)-1; } else { cout<<a+b-(b-a)-1; } return 0; }

          • 0
            @ 2024-3-3 17:02:43
            #include <iostream>
            using namespace std;
            int main()
            {
                int a;
                int b;
                int c;
                cin >> a >> b;
                if(b > a)
                {
                    c = a;
                    a = b;
                    b = c;
                }
                cout << b * 2 - 1 << endl;
                return 0;
            }
            
            • 0
              @ 2024-3-3 17:02:38

              必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

              #include <iostream>
              using namespace std;
              int main()
              {
                  int a;
                  int b;
                  int c;
                  cin >> a >> b;
                  if(b > a)
                  {
                      c = a;
                      a = b;
                      b = c;
                  }
                  cout << b * 2 - 1 << endl;
                  return 0;
              }
              
              • 0
                @ 2024-3-3 17:02:38

                必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                #include <iostream>
                using namespace std;
                int main()
                {
                    int a;
                    int b;
                    int c;
                    cin >> a >> b;
                    if(b > a)
                    {
                        c = a;
                        a = b;
                        b = c;
                    }
                    cout << b * 2 - 1 << endl;
                    return 0;
                }
                
                • 0
                  @ 2024-3-3 17:02:34

                  必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int a;
                      int b;
                      int c;
                      cin >> a >> b;
                      if(b > a)
                      {
                          c = a;
                          a = b;
                          b = c;
                      }
                      cout << b * 2 - 1 << endl;
                      return 0;
                  }
                  
                  • 0
                    @ 2024-3-3 17:02:33

                    必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                    #include <iostream>
                    using namespace std;
                    int main()
                    {
                        int a;
                        int b;
                        int c;
                        cin >> a >> b;
                        if(b > a)
                        {
                            c = a;
                            a = b;
                            b = c;
                        }
                        cout << b * 2 - 1 << endl;
                        return 0;
                    }
                    
                    • 0
                      @ 2024-3-3 17:02:33

                      必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                      #include <iostream>
                      using namespace std;
                      int main()
                      {
                          int a;
                          int b;
                          int c;
                          cin >> a >> b;
                          if(b > a)
                          {
                              c = a;
                              a = b;
                              b = c;
                          }
                          cout << b * 2 - 1 << endl;
                          return 0;
                      }
                      
                      • 0
                        @ 2024-3-3 17:02:31

                        必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                        #include <iostream>
                        using namespace std;
                        int main()
                        {
                            int a;
                            int b;
                            int c;
                            cin >> a >> b;
                            if(b > a)
                            {
                                c = a;
                                a = b;
                                b = c;
                            }
                            cout << b * 2 - 1 << endl;
                            return 0;
                        }
                        
                        • 0
                          @ 2024-3-3 17:02:31

                          必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                          #include <iostream>
                          using namespace std;
                          int main()
                          {
                              int a;
                              int b;
                              int c;
                              cin >> a >> b;
                              if(b > a)
                              {
                                  c = a;
                                  a = b;
                                  b = c;
                              }
                              cout << b * 2 - 1 << endl;
                              return 0;
                          }
                          
                          • 0
                            @ 2024-3-3 17:02:31

                            必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                                int a;
                                int b;
                                int c;
                                cin >> a >> b;
                                if(b > a)
                                {
                                    c = a;
                                    a = b;
                                    b = c;
                                }
                                cout << b * 2 - 1 << endl;
                                return 0;
                            }
                            
                            • 0
                              @ 2024-3-3 17:02:31

                              必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                              #include <iostream>
                              using namespace std;
                              int main()
                              {
                                  int a;
                                  int b;
                                  int c;
                                  cin >> a >> b;
                                  if(b > a)
                                  {
                                      c = a;
                                      a = b;
                                      b = c;
                                  }
                                  cout << b * 2 - 1 << endl;
                                  return 0;
                              }
                              
                              • 0
                                @ 2024-3-3 17:02:30

                                必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                                #include <iostream>
                                using namespace std;
                                int main()
                                {
                                    int a;
                                    int b;
                                    int c;
                                    cin >> a >> b;
                                    if(b > a)
                                    {
                                        c = a;
                                        a = b;
                                        b = c;
                                    }
                                    cout << b * 2 - 1 << endl;
                                    return 0;
                                }
                                
                                • 0
                                  @ 2024-3-3 17:02:29

                                  必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                                  #include <iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int a;
                                      int b;
                                      int c;
                                      cin >> a >> b;
                                      if(b > a)
                                      {
                                          c = a;
                                          a = b;
                                          b = c;
                                      }
                                      cout << b * 2 - 1 << endl;
                                      return 0;
                                  }
                                  
                                  • 0
                                    @ 2024-3-3 17:02:29

                                    必须都给我看懂好吧~ 这还不懂,小心我半夜来你家马桶盖(啊呸,是借)

                                    #include <iostream>
                                    using namespace std;
                                    int main()
                                    {
                                        int a;
                                        int b;
                                        int c;
                                        cin >> a >> b;
                                        if(b > a)
                                        {
                                            c = a;
                                            a = b;
                                            b = c;
                                        }
                                        cout << b * 2 - 1 << endl;
                                        return 0;
                                    }
                                    
                                    • 0
                                      @ 2024-2-15 16:54:23
                                      #include <bits/stdc++.h>
                                          using namespace std;
                                          int main()
                                          {
                                              int a,b,c;
                                              cin >> a >> b;
                                              if(a>b)//判断那个大
                                              {
                                                  c=a-b;
                                              }
                                              else
                                              {
                                                  c=b-a;
                                              }
                                              cout << a+b-c-1;//结果
                                              return 0;
                                          }
                                      
                                      

                                      信息

                                      ID
                                      522
                                      时间
                                      1000ms
                                      内存
                                      128MiB
                                      难度
                                      7
                                      标签
                                      递交数
                                      18999
                                      已通过
                                      3895
                                      上传者