codeforces 849B Tell Your World(计算几何)
来源:互联网 发布:淘宝的优质网店 编辑:程序博客网 时间:2024/05/29 09:38
题意:
给你一个直角坐标系,上面有n个点,问你能不能画两条不重合的平行线,使得每条平行线至少经过一个点,且所有的点都在其中一条平行线上。
思路:
提取前三个点,根据题目要求,这两条线其中一条必经过前三个点中至少两个点。所以可以枚举第一条平行线,找有没有符合条件的另一条平行线。
代码:
#include <bits/stdc++.h>using namespace std;typedef long long ll;double arr[1001];int pd[1001];int n;bool solve(int x1,int x2){ memset(pd,0,sizeof(pd)); pd[x1] = 1; pd[x2] = 1; double xl = (arr[x1]-arr[x2])/(x1-x2); bool flag = false; for(int i = 1;i<=n;i++) { if(pd[i]==0) { double xxl = (arr[i]-arr[x1])/(i-x1); if(xl==xxl) pd[i] = 1; } } int num = 0; int pos; double xll; for(int i = 1;i<=n;i++) { if(pd[i]==0) { flag = true; if(num==0) { pos = i; num++; } else if(num==1) { xll = (arr[i]-arr[pos])/(i-pos); if(xll!=xl) return false; num++; } else { double xxl = (arr[i]-arr[pos])/(i-pos); if(xxl!=xll) return false; } } } return flag;}int main(){ scanf("%d",&n); for(int i = 1;i<=n;i++) scanf("%lf",arr+i); if(solve(1,2)||solve(1,3)||solve(2,3)) printf("Yes"); else printf("No"); return 0;}
阅读全文
1 0
- codeforces 849B Tell Your World(计算几何)
- Codeforces 849 B. Tell Your World(计算几何)
- Codeforces 849B. Tell Your World 计算几何
- Codeforces 849 B Tell Your World
- CodeForces 849B Tell Your World 点线
- codeforces 849B. Tell Your World
- codeforces 849B Tell Your World
- Codeforces-849B Tell Your World
- CodeForces #431Div. 2 849B Tell your world 几何 暴力 枚举
- Codeforces 894B. Tell Your World
- Codeforces Tell Your World
- Codeforces Round #431 (Div. 2) B. Tell Your World
- Codeforces Round #431 (Div. 2)B Tell Your World
- Codeforces Round #431 (Div. 2) 849B Tell Your World(暴力+枚举)
- CodeFroces 849B. Tell Your World (鸽巢原理)
- Codeforces Round #431 (Div. 2) B. Tell Your World(向量积)
- Codeforces Round #431 (Div. 2) B. Tell Your World(技巧性模拟+精度坑死人系列)
- B. Tell Your World Codeforces Round #431 (Div. 2)(简单模拟)
- 项目——通过自动回复机器人学Mybatis(六)
- 【NOIP模拟】赤壁情(DP)
- BZOJ1297: [SCOI2009]迷路(矩阵优化DP)
- 笔试复习_TCP/IP(三)
- C++ 返回数组问题
- codeforces 849B Tell Your World(计算几何)
- 牛客网--研究生复试--约数的个数
- [Caffe]史上最全的caffe安装过程
- 4399小游戏 十滴水 求解器(遗传算法尝试)
- 在EXCEL中快速输入数据的方法
- Python中文字输出乱码
- leetcode 50. Pow(x, n) 一个简单的分治算法的应用
- Python爬虫(一):爬取单页面
- static详解