Kadj Squares - POJ 3347
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std; const int MAXN = ;
const double EPS = 1e-; struct Line{int L, R, len;}a[MAXN]; int main()
{
int N; while(scanf("%d", &N) != EOF && N)
{
memset(a, , sizeof(a)); for(int i=; i<N; i++)
{
scanf("%d", &a[i].len);
for(int j=; j<i; j++)
a[i].L = max(a[i].L, a[j].R-abs(a[j].len-a[i].len));
a[i].R = a[i].L + a[i].len * ;
} for(int i=; i<N; i++)
{
for(int j=; j<i; j++)
{
if(a[i].L < a[j].R && a[i].len < a[j].len)
a[i].L = a[j].R;
}
for(int j=i+; j<N; j++)
{
if(a[i].R > a[j].L && a[i].len < a[j].len)
a[i].R = a[j].L;
}
} for(int k=, i=; i<N; i++)
{
if(a[i].L < a[i].R)
{
if(k++)printf(" ");
printf("%d", i+);
}
}
printf("\n");
} return ;
}
Kadj Squares - POJ 3347的更多相关文章
- POJ 3347 Kadj Squares
Kadj Squares Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 2132 Accepted: 843 Descr ...
- poj3347 Kadj Squares【计算几何】
Kadj Squares Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 3594 Accepted: 1456 Desc ...
- poj3347 Kadj Squares (计算几何)
D - Kadj Squares Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Su ...
- POJ 3347 Kadj Squares (计算几何)
题目: Description In this problem, you are given a sequence S1, S2, ..., Sn of squares of different si ...
- POJ 3347 Kadj Squares (计算几何+线段相交)
题意:从左至右给你n个正方形的边长,接着这些正方形都按照旋转45度以一角为底放置坐标轴上,最左边的正方形左端点抵住y轴,后面的正方形依次紧贴前面所有正方形放置,问从上方向下看去,有哪些正方形是可以被看 ...
- 简单几何(线段覆盖) POJ 3347 Kadj Squares
题目传送门 题意:告诉每个矩形的边长,它们是紧贴着的,问从上往下看,有几个还能看到. 分析:用网上猥琐的方法,将边长看成左端点到中心的距离,这样可以避免精度问题.然后先求出每个矩形的左右端点,然后如果 ...
- POJ 3347 Kadj Squares (线段覆盖)
题目大意:给你几个正方形的边长,正方一个顶点在x轴上然后边与x轴的夹角为45度,每个正方形都是紧贴的,问从上面看能看的正方形的编号 题目思路:线段覆盖,边长乘上2防止产生小数,求出每个正方形与x轴平行 ...
- POJ 3347 Kadj Squares 计算几何
求出正方形的左右端点,再判断是否覆盖 #include <iostream> #include <cstdio> #include <cstring> #inclu ...
- [poj] 3347 Kadj Square || 计算几何的“线段覆盖”
原题 多组数据,给出n个正方形的边长,使他们以45度角倾斜的情况下最靠左(在第一象限内),如图.求从上看能看到哪几个完整的正方形. 借鉴于https://www.cnblogs.com/Ritchie ...
随机推荐
- ios动力特效,最重要的一点 属性保持(写了动力特效但是没效果的原因就在这里)
@property (nonatomic, strong) UIDynamicItemBehavior *square1PropertiesBehavior; @property (nonatomic ...
- C# DataTable的詳細用法 - hcw_peter的专栏 - 博客频道 - CSDN
C# DataTable的詳細用法 - hcw_peter的专栏 - 博客频道 - CSDN.NET 在项目中经常用到DataTable,如果DataTable使用得当,不仅能使程序简洁实用,而且能够 ...
- Javascript面试题浅析
分享几道JavaScript相关的面试题. 字符串反转 这这里提供了两种解题思路.如果各位读者还有其他的思路,可以分享交流! 第一方法: function reverse(str){ var sp = ...
- java_设计模式_状态模式_State Pattern(2016-08-16)
定义: 当一个对象的内在状态改变时允许改变其行为,这个对象看起来像是改变了其类. 类图: 状态模式所涉及到的角色有: ● 环境(Context)角色,也成上下文:定义客户端所感兴趣的接口,同时维护一个 ...
- [Introduction to programming in Java 笔记] 1.3.7 Converting to binary 十进制到二进制的转换
public class Binary { public static void main(String[] args) { // Print binary representation of N. ...
- Problem 1010 - 素数环问题
#include<iostream> #include<string> #include<algorithm> #include<vector> #in ...
- 20 Valid Parentheses(匹配括号)
题目意思:判断一个字符串(){}[]是否符合 思路:用栈ps:实习一个多月了,代码也刷不动了,状态真不是一般的差 class Solution { public: bool isValid(strin ...
- sencha touch中按钮的ui配置选项值及使用效果
- python核心编程2第二章课后练习
2-1 变量, print 和字符串格式化运算符.启动交互式解释器.给一些变量赋值(字符串,数值等等)并通过输入变量名显示它们的值.再用 print 语句做同样的事.这二者有何区别? 也尝试着使用字符 ...
- iOS: 布局可视化语法 Visual Format Syntax
可视化语法 Visual Format Syntax The following are examples of constraints you can specify using the visua ...