[ABC223E] Placing Rectangles 题解
1.AT_abc333_e [ABC333E] Takahashi Quest 题解2.[ABC265F] Manhattan Cafe 题解3.[ABC271E] Subsequence Path 题解4.[ABC273D] LRUD Instructions 题解5.P8085 [COCI2011-2012#4] KRIPTOGRAM 题解6.[ABC238F] Two Exams 题解7.[ABC217F] Make Pair 题解8.[ABC219F] Cleaning Robot 题解9.[ABC219E] Moat 题解10.[ABC221D] Online games 题解11.[ABC221E] LEQ 题解
12.[ABC223E] Placing Rectangles 题解
13.[ABC211D] Number of Shortest paths 题解14.[ABC211F] Rectilinear Polygons 题解15.[ABC223F] Parenthesis Checking 题解16.CF154C Double Profiles 题解17.[ABC208D] Shortest Path Queries 2 题解18.[ABC212E] Safety Journey 题解19.[ABC229E] Graph Destruction 题解20.[ABC240E] Ranges on Tree 题解21.[ABC261E] Many Operations 题解22.P10842 【MX-J2-T3】Piggy and Trees 题解[ABC223E] Placing Rectangles 题解
思路解析
根据题目可知,其实三个长方形无非只有以下两种摆放方式。
若大长方形长为
注意大长方形的长宽可以互换,小长方形的顺序可以互换。
code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
ll x, y, a, b, c;
bool check() {
ll ax = ceil((double)a / x), bx = ceil((double)b / x), cx = ceil((double)c / x);
if(ax + bx + cx <= y) return true;
ll yy = y - ax;
if(yy <= 0) return false;
ll by = ceil((double)b / yy), cy = ceil((double)c / yy);
if(by + cy <= x) return true;
return false;
}
int main() {
cin >> x >> y >> a >> b >> c;
bool ans = check();
swap(a, b); ans |= check();
swap(a, c); ans |= check();
swap(x, y); ans |= check();
swap(a, b); ans |= check();
swap(a, c); ans |= check();
if(ans) puts("Yes");
else puts("No");
return 0;
}
合集:
题解
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架