3 条题解

  • 0
    @ 2024-11-24 16:13:32
    #include<iostream> 
    #include<string> 
    #include <algorithm> 
    using namespace std; 
    int main(){ 
        string n; 
        cin>>n; 
        int r,g,b; 
        r=g=b=0; 
        sort(n.begin(),n.end()); 
        cout<<n<<endl; 
        for(int i=0;i<n.size();i++)
        { 
            if(n[i]=='R')
            { 
                r++; 
            }
            else if(n[i]=='G')
            { 
                g++; 
            }
            else if(n[i]=='B')
            { 
                b++; 
            } 
        } 
        if(r/g/2==b/3)
        { 
            cout<<r; 
        }
        else
        { 
            if(r<=g/2&&r<=b/3)
            { 
                cout<<r; 
            }
            else if(g/2<=r&&g/2<=b/3)
            { 
                cout<<g/2; 
            }
            else if(b/3<=r&&b/3<=g/2)
            { 
                cout<<b/3; 
            } 
        } 
        return 0; 
    }
    
    • 0
      @ 2024-11-24 11:26:50
      #include<iostream> 
      #include<string> 
      #include <algorithm> 
      using namespace std; 
      int main(){ 
          string n; 
          cin>>n; 
          int r,g,b; 
          r=g=b=0; 
          sort(n.begin(),n.end()); 
          cout<<n<<endl; 
          for(int i=0;i<n.size();i++)
          { 
              if(n[i]=='R')
              { 
                  r++; 
              }
              else if(n[i]=='G')
              { 
                  g++; 
              }
              else if(n[i]=='B')
              { 
                  b++; 
              } 
          } 
          if(r/g/2==b/3)
          { 
              cout<<r; 
          }
          else
          { 
              if(r<=g/2&&r<=b/3)
              { 
                  cout<<r; 
              }
              else if(g/2<=r&&g/2<=b/3)
              { 
                  cout<<g/2; 
              }
              else if(b/3<=r&&b/3<=g/2)
              { 
                  cout<<b/3; 
              } 
          } 
          return 0; 
      }
      
      • 0
        @ 2023-9-17 15:45:22

        #include<iostream> #include<string> #include <algorithm> using namespace std; int main() { string n; cin>>n; int r,g,b; r=g=b=0; sort(n.begin(),n.end()); cout<<n<<endl; for(int i=0;i<n.size();i++) { if(n[i]'R') { r++; }else if(n[i]'G') { g++; }else if(n[i]'B') { b++; } } if(r/1g/2==b/3){ cout<<r; }else{ if(r<=g/2&&r<=b/3){ cout<<r; }else if(g/2<=r&&g/2<=b/3){ cout<<g/2; }else if(b/3<=r&&b/3<=g/2){ cout<<b/3; } } return 0; }

        • 1

        信息

        ID
        88
        时间
        1000ms
        内存
        256MiB
        难度
        6
        标签
        递交数
        212
        已通过
        64
        上传者