题解 | #小红的最小最大#

小红的最小最大

https://ac.nowcoder.com/acm/contest/85687/A

纯暴力哈哈哈哈哈哈哈

#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ans = 0;
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0 ; k < 2; k++)
            {
                int res = 0;
                if(k == 0)
                {
                    switch(i)
                    {
                        case 0:res = a+b;
                            break;
                        case 1:res = a-b;
                            break;
                        case 2: res = a*b;
                            break;
                        case 3: res = a/b;
                            break;
                    }
                      switch(j)
                    {
                        case 0:res = res+c;
                            break;
                        case 1:res = res-c;
                            break;
                        case 2: res = res *c;
                            break;
                        case 3: res = res/c;
                            break;
                    }
                }
                else{
                      switch(j)
                    {
                        case 0:res = b+c;
                            break;
                        case 1:res = b-c;
                            break;
                        case 2: res = b*c;
                            break;
                        case 3: res = b/c;
                            break;
                    }
                      switch(i)
                    {
                        case 0:res = a+res;
                            break;
                        case 1:res = a-res;
                            break;
                        case 2: res = a*res;
                            break;
                        case 3: res = a/res;
                            break;
                    }
                }
                ans = max(ans,res);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
//我就想问服不服?哈哈哈哈哈,
全部评论

相关推荐

shtdbb_:还不错,没有让你做了笔试再挂你
点赞 评论 收藏
分享
Natrium_:这时间我以为飞机票
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务