跳到正文

题解

P11857 [CCC 2025 Senior] 挂画 题解

HAPPINESS23333约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年3月8日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 1 分钟
题目
P11857

版本

  1. v1当前

好像是一道数学题呢(思考)

题目思路

看到这个题目,其实我们就可以想到有两种放置方法,一种是左右放,一种是上下放

左右放

长=a+x长=a+x

宽=max(b,y)宽=max(b,y)

上下放

长=max(a,x)长=max(a,x)

宽=b+y宽=b+y

那么代码就可以很容易得得到啦(* ^▽^ *)

C++
#include<bits/stdc++.h>
using namespace std;
int a,b,x,y;
int main()
{
	cin>>a>>b>>x>>y;
	int final_out1,final_out2;
	//左右放
	final_out1=2*(a+x+max(b,y));
	//上下放
	final_out2=2*(b+y+max(a,x));
	//比较然后输出
	cout<<min(final_out1,final_out2);
	return 0;
}
原文