Uva 3226 Symmetry】的更多相关文章

题目给出一些点的坐标(横坐标,纵坐标),没有重叠的点,求是否存在一条竖线(平行于y轴的线),使线两边的点左右对称. 我的思路:对于相同的纵坐标的点,即y值相同的点,可以将x的总和计算出,然后除以点的数目,即可得到对称轴的x坐标.所以,对于不同的y值,可以算出这个y值对应的点的对称轴的x坐标,只要观察这些x坐标的值是否相等即可.如果相同,则存在一条竖线满足题意.如果出现不相同,则不存在符合题意的竖线. 注意点:计算后的x的值可能为小数,故需要用double保存. /* UvaOJ 1595 Eme…
思路:首先,如果这些点对称,那么它们的对称轴是x = m(m是所有点横坐标的平均值):   把这些点放到一个集合里,然后扫描每个点,计算出它关于x = m的对称点,看这个点是否在集合里面.   如果有一个不在的话,说明不能构成对称图形. #include <iostream> #include <algorithm> #include <cstdio> #include <set> using namespace std; struct Point{ int…
给出平面上N(N<=1000)个点.问是否可以找到一条竖线,使得所有点左右对称,如图所示: 则左边的图形有对称轴,右边没有.   Sample Input  3 5 -2 5 0 0 6 5 4 0 2 3 4 2 3 0 4 4 0 0 0 4 5 14 6 10 5 10 6 14 Sample Output YES NO YES 写题永远都是wrong answer..... #include <cstdio> #include <iostream> #include…
We call a figure made of points is left-right symmetric as it is possible to fold the sheet of paper along a vertical line and to cut the figure into two identical halves.For example, if a figure exists five points, which respectively are (-2,5),(0,0…
题意:给出n个在直角坐标系上的点,问你能不能找出一条竖轴(即垂直于x的轴)使得所有的点根据这条轴对称,能则输出YES,否则输出NO 分析:首先需要找到对称轴的值,将所有n个点的x轴的值加起来然后去除以n便可得(证明在下方).对于各个点的处理就是将每一个点的x,y组成一个pair丢到set里面去让其自动根据x轴的大小来排序,然后遍历一遍set,根据对称轴信息就可以得到对称点,如果有对称点不在set里面那就是NO的情况,否则反之! 但是在偶数个点的时候,对称轴的值会出现小数点,涉及到精度问题,那有没…
颓废的一个下午,一直在切水题,(ˉ▽ ̄-) 首先如果这些点是对称的话,那么它们的对称轴就是x = m,m是横坐标的平均值. 把这些点放到一个集合里,然后扫描每个点,计算出它关于x = m的对称点,看这个点是否在集合里面. 如果有一个不在的话,说明不能构成对称图形. #include <cstdio> #include <algorithm> #include <set> using namespace std; struct Point { int x, y; Poin…
题意:给出一个点集,问这个集合有没有中心点使点集对称,这个点可以是点集中的点也可以不是点集的点. 解法:一开始我枚举每两个点连线的中点……结果T了orz当时也不知道怎么想的…… 将点按横坐标排序,如果点集有中心点则中心点一定是排序后排在中间的那个点(n为奇数)或者中间两个点的连线中点(n为偶数),然后判断一下是不是中心点即可. 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<…
题目 题目     分析 理清思路,上模拟.     代码 #include <bits/stdc++.h> using namespace std; const int maxn=10005,INF=1<<15; int vis[maxn],leftx,rightx,x[maxn],y[maxn],t,n; void init() { memset(vis,0,sizeof(vis)); leftx=INF;rightx=-INF; } int main() { scanf(&q…
  The figure shown on the left is left-right symmetric as it is possible to fold the sheet of paper along a vertical line, drawn as a dashed line, and to cut the figure into two identical halves. The figure on the right is not left-right symmetric as…
例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h> #include<cmath> #include<string> #include<queue> #include<stack> #include<vector> #include<map> #include<set>…