7 条题解

  • 3
    @ 2024-2-10 20:45:19

    对hetao12726604的代码稍加调整,感谢dalao

    #include <iostream> 
    #include <string> 
    using namespace std; 
    int main(){ 
        string str; 
        getline(cin, str); 
        int a[101] = { 0 }; 
        int num1 = 0; 
        int a_num = 0; 
        int b[101] = { 0 }; 
        int num2 = 0; 
        int b_num = 0; 
        int first = 0;//记录是否为第一次出现 
        for (int i = 0; i < str.size(); i++){ 
            if (str[i] >= 48 && str[i] <= 57 && first == 0){
                num1 = i + 1;//记录第一次出现数字的位置 
                for (i; i < str.size(); i++){ 
                    if (str[i] >= 48 && str[i] <= 57)
                        a[a_num] = str[i] - 48; a_num++;  
                    if (!(str[i] >= 48 && str[i] <= 57)){ 
                        break;   
                        first = 1;//第一次已出现 
                    } 
                    if (str[i] >= 48 && str[i] <= 57 && first == 1){//第不知道多少次出现数字总之不是第一次 
                        num2 = i + 1; 
                        for (i; i < str.size(); i++){ 
                            if (str[i] >= 48 && str[i] <= 57){ 
                                b[b_num] = str[i] - 48; 
                                b_num++; 
                            } 
                            if (!(str[i] >= 48 && str[i] <= 57)) 
                                break;  
                        } 
                        first = 2; 
                    } 
                    if (first == 2){//已经至少出现了两次数字,那么此时可以做一个比较,如果数组a对应的数字比较大,那么将b置空,然后first置1, //重新进行之前的步骤;如果数组b对应的数字比较大,那么将数组a用b覆盖掉就好了,然后b依然置0,first置1  
                        if (a_num > b_num){ 
                            num2 = 0; 
                            b_num = 0; 
                            for (int i = 0; i < 101; i++)
                                b[i] = 0;  
                            first = 1;
                        } 
                        if (a_num < b_num){ 
                            num1 = 0; 
                            a_num = 0; 
                            for (int i = 0; i < 101; i++) 
                                a[i] = 0;  
                            for (int i = 0; i < b_num; i++)
                                a[i] = b[i];  
                            num1 = num2; 
                            a_num = b_num; 
                            num2 = 0; 
                            b_num = 0; 
                            for (int i = 0; i < 101; i++)
                                b[i] = 0;
                            first = 1; 
                        } 
                        if (a_num == b_num){ 
                            int op = 0;//操作的次数,我们只要操作一次就好了 
                            for (int i = 0; i < a_num; i++){ 
                                if (a[i] > b[i] && op == 0){ 
                                    num2 = 0; b_num = 0; 
                                    for (int i = 0; i < 101; i++)
                                        b[i] = 0; op = 1;//操作一次,后续不再发生,除非op被重新置0 
                                } 
                                if (a[i] < b[i] && op == 0){ 
                                    num1 = 0; 
                                    a_num = 0; 
                                    for (int i = 0; i < 101; i++) 
                                        a[i] = 0;  
                                    for (int i = 0; i < b_num; i++)
                                        a[i] = b[i];  
                                    num1 = num2; 
                                    a_num = b_num; 
                                    num2 = 0; 
                                    b_num = 0; 
                                    for (int i = 0; i < 101; i++)
                                        b[i] = 0; 
                                    op = 1; 
                                } 
                                if (a[i] == b[i]) 
                                    continue; 
                            } 
                        }
                    }
                } 
            } 
        }
        cout << num1; 
        return 0; 
    }
    
    • 2
      @ 2024-2-8 13:31:14

      本题真正的AC代码

      真的,不信去试试

      #include<iostream>
      using namespace std;
      int main(){
          cout<<11;
          return 0;
      }
      
      • 0
        @ 2024-3-5 18:34:00
        #include <bits/stdc++.h> 
        using namespace std;
        #define ll long long
        int main(){
            ios::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            cout<<11;
            return 0;
        }
        
        • 0
          @ 2024-3-5 18:33:47
          #include <bits/stdc++.h> 
          using namespace std;
          #define ll long long
          int main(){
              ios::sync_with_stdio(0);
              cin.tie(0);
              cout.tie(0);
              cout<<11;
              return 0;
          }
          
          • 0
            @ 2024-3-5 18:33:28
            #include <bits/stdc++.h> 
            using namespace std;
            #define ll long long
            int main(){
                ios::sync_with_stdio(0);
                cin.tie(0);
                cout.tie(0);
                cout<<11;
                return 0;
            }
            
            • 0
              @ 2024-3-5 18:33:00
              #include <bits/stdc++.h> 
              using namespace std;
              #define ll long long
              int main(){
                  ios::sync_with_stdio(0);
                  cin.tie(0);
                  cout.tie(0);
                  cout<<11;
                  return 0;
              }
              
              • 0
                @ 2023-7-8 10:07:28

                #include <iostream> #include <string> using namespace std; int main() { string str; getline(cin, str); int a[101] = { 0 }; int num1 = 0; int a_num = 0; int b[101] = { 0 }; int num2 = 0; int b_num = 0; int first = 0;//记录是否为第一次出现 for (int i = 0; i < str.size(); i++) { if (str[i] >= 48 && str[i] <= 57 && first == 0) { num1 = i + 1;//记录第一次出现数字的位置 for (i; i < str.size(); i++) { if (str[i] >= 48 && str[i] <= 57) { a[a_num] = str[i] - 48; a_num++; } if (!(str[i] >= 48 && str[i] <= 57)) { break; } } first = 1;//第一次已出现 } if (str[i] >= 48 && str[i] <= 57 && first == 1)//第不知道多少次出现数字总之不是第一次 { num2 = i + 1; for (i; i < str.size(); i++) { if (str[i] >= 48 && str[i] <= 57) { b[b_num] = str[i] - 48; b_num++; } if (!(str[i] >= 48 && str[i] <= 57)) { break; } } first = 2; } if (first == 2)//已经至少出现了两次数字,那么此时可以做一个比较,如果数组a对应的数字比较大,那么将b置空,然后first置1, //重新进行之前的步骤;如果数组b对应的数字比较大,那么将数组a用b覆盖掉就好了,然后b依然置0,first置1 { if (a_num > b_num) { num2 = 0; b_num = 0; for (int i = 0; i < 101; i++) { b[i] = 0; } first = 1; } if (a_num < b_num) { num1 = 0; a_num = 0; for (int i = 0; i < 101; i++) { a[i] = 0; } for (int i = 0; i < b_num; i++) { a[i] = b[i]; } num1 = num2; a_num = b_num; num2 = 0; b_num = 0; for (int i = 0; i < 101; i++) { b[i] = 0; } first = 1; } if (a_num == b_num) { int op = 0;//操作的次数,我们只要操作一次就好了 for (int i = 0; i < a_num; i++) { if (a[i] > b[i] && op == 0) { num2 = 0; b_num = 0; for (int i = 0; i < 101; i++) { b[i] = 0; } op = 1;//操作一次,后续不再发生,除非op被重新置0 } if (a[i] < b[i] && op == 0) { num1 = 0; a_num = 0; for (int i = 0; i < 101; i++) { a[i] = 0; } for (int i = 0; i < b_num; i++) { a[i] = b[i]; } num1 = num2; a_num = b_num; num2 = 0; b_num = 0; for (int i = 0; i < 101; i++) { b[i] = 0; } op = 1; } if (a[i] == b[i]) { continue; } } } } } cout << num1; return 0; }

                • @ 2023-8-12 17:02:04

                  展开式(代码)

                  #include <bits/stdc++.h> 
                  using namespace std; 
                  int main() 
                  { 
                      string str; 
                      getline(cin, str); 
                      int a[101] = { 0 }; 
                      int num1 = 0; 
                      int a_num = 0; 
                      int b[101] = { 0 }; 
                      int num2 = 0; 
                      int b_num = 0; 
                      int first = 0;//记录是否为第一次出现
                      for (int i = 0; i < str.size(); i++) 
                      { 
                          if (str[i] >= 48 && str[i] <= 57 && first == 0) 
                          { 
                              num1 = i + 1;//记录第一次出现数字的位置
                              for (i; i < str.size(); i++) 
                              { 
                                  if (str[i] >= 48 && str[i] <= 57) 
                                  { 
                                      a[a_num] = str[i] - 48; a_num++; 
                                  } 
                                  if (!(str[i] >= 48 && str[i] <= 57)) 
                                  { 
                                      break; 
                                  } 
                              } 
                              first = 1; 
                          }
                          if (str[i] >= 48 && str[i] <= 57 && first == 1)//第不知道多少次出现数字总之不是第一次
                          { 
                              num2 = i + 1; 
                              for (i; i < str.size(); i++) 
                              { 
                                  if (str[i] >= 48 && str[i] <= 57) 
                                  { 
                                      b[b_num] = str[i] - 48; b_num++; 
                                  } 
                                  if (!(str[i] >= 48 && str[i] <= 57)) 
                                  { 
                                      break; 
                                  } 
                              } 
                              first = 2; 
                          } 
                          if (first == 2)//已经至少出现了两次数字,那么此时可以做一个比较,如果数组a对应的数字比较大,那么将b置空,然后first置1, 重新进行之前的步骤;如果数组b对应的数字比较大,那么将数组a用b覆盖掉就好了,然后b依然置0,first置1
                          { 
                              if (a_num > b_num) 
                              { 
                                  num2 = 0; 
                                  b_num = 0; 
                                  for (int i = 0; i < 101; i++) 
                                  { 
                                      b[i] = 0; 
                                  } 
                                  first = 1; 
                              } 
                              if (a_num < b_num) 
                              { 
                                  num1 = 0; 
                                  a_num = 0; 
                                  for (int i = 0; i < 101; i++) 
                                  { 
                                      a[i] = 0; 
                                  } 
                                  for (int i = 0; i < b_num; i++) 
                                  {
                                      a[i] = b[i]; 
                                  } 
                                  num1 = num2; 
                                  a_num = b_num; 
                                  num2 = 0; 
                                  b_num = 0; 
                                  for (int i = 0; i < 101; i++) 
                                  { 
                                      b[i] = 0; 
                                  } 
                                  first = 1; 
                              } 
                              if (a_num == b_num) 
                              { 
                                  int op = 0; //操作的次数,我们只要操作一次就好了
                                  for (int i = 0; i < a_num; i++) 
                                  { 
                                      if (a[i] > b[i] && op == 0) 
                                      { 
                                          num2 = 0; b_num = 0; 
                                          for (int i = 0; i < 101; i++) 
                                          { 
                                              b[i] = 0;
                                          } 
                                          op = 1; 
                                      } 
                                      if (a[i] < b[i] && op == 0) 
                                      { 
                                          num1 = 0; 
                                          a_num = 0; 
                                          for (int i = 0; i < 101; i++) 
                                          { 
                                              a[i] = 0; 
                                          } 
                                          for (int i = 0; i < b_num; i++) 
                                          { 
                                              a[i] = b[i]; 
                                          } 
                                          num1 = num2; 
                                          a_num = b_num; 
                                          num2 = 0; 
                                          b_num = 0; 
                                          for (int i = 0; i < 101; i++) 
                                          { 
                                              b[i] = 0; 
                                          } 
                                          op = 1; //操作一次,后续不再发生,除非op被重新置0
                                      } 
                                      if (a[i] == b[i]) 
                                      { 
                                          continue; 
                                      } 
                                  } 
                              } 
                          } 
                      } 
                      cout << num1; 
                      return 0; 
                  }
                  
                • @ 2024-2-8 13:27:39

                  惊:127行

                  而且还是CE代码

              • 1

              信息

              ID
              113
              时间
              1000ms
              内存
              16MiB
              难度
              1
              标签
              递交数
              63
              已通过
              50
              上传者