CodeForces
来源:互联网 发布:冬天四件套绒淘宝 编辑:程序博客网 时间:2024/06/03 14:44
题目链接:http://codeforces.com/problemset/problem/837/C
题目大意:选择两个纸条,使其能在板上同时贴下,并且是与板平行的,可以旋转90°,求可以贴下的两个纸条的最大面积。
解题思路:暴力枚举,然后讨论,详细见代码。
AC代码:
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct Node{ int _x, _y; Node(int x = 0, int y = 0) :_x(x), _y(y) {}}node[100 + 5];int main(){ int n, a, b; scanf("%d%d%d", &n, &a, &b); if (a > b) { int tmp = a; a = b; b = tmp; } for (int i = 0;i < n;++i) { int x, y;scanf("%d%d", &x, &y); if (x > y) { int tmp = x; x = y; y = tmp; } node[i] = Node(x, y); } int mx = 0; for (int i = 0;i<n;++i) for (int j = i + 1;j < n;++j) { if (min(node[i]._x, node[j]._x) > a) continue; int area = node[i]._x*node[i]._y + node[j]._x*node[j]._y; if (node[i]._x + node[j]._x <= a) { if (node[i]._y <= b&&node[j]._y <= b) mx = max(area, mx); } else { if (node[i]._x <= a&&node[j]._x <= a&&node[i]._y + node[j]._y <= b) mx = max(area, mx); else if (node[j]._y <= a&&node[i]._y + node[j]._x <= b&&node[i]._x<=a) mx = max(area, mx); else if (node[i]._y <= a&&node[i]._x + node[j]._y <= b&&node[j]._x<=a) mx = max(area, mx); else if (node[i]._y <= a&&node[j]._y <= a&&node[i]._x + node[j]._x <= b) mx = max(area, mx); } } printf("%d\n", mx); return 0;}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 找规律 permutation
- UVA 442 栈解析表达式
- oracle(四)
- Java反射
- SQL ORDER BY 子句
- CodeForces
- POJ 2503 Babelfish(STL、二分、字典树、哈希)
- caffe源码追踪-net
- MP4全介绍
- idea开发中部署war和war exploded的区别
- 推荐两个安装Cygwin时的快速源
- OSPF特性和OSPF术语解释
- 训练总结 8.9
- GitHub上Top20个 Python 语言机器学习项目