UVA1595Symmetry

来源:互联网 发布:罗马复兴兵种数据 编辑:程序博客网 时间:2024/05/15 18:09
//UVA1595Symmetry#include<cstdio>#include<iostream>#include<map>#include<string> #include<cstring>using namespace std;const int MAXN = 2000;typedef pair<double, double> LL;LL dot_pair[MAXN];map<LL, int> Match;int main() {int kase = 0;scanf("%d", &kase);while(kase--) {int n = 0;scanf("%d", &n);double sum = 0;for(int i = 0; i < n; i++) {double a, b;scanf("%lf%lf", &a, &b);dot_pair[i].first = a;//printf("a = %.0f\n",  a);sum += a;dot_pair[i].second = b;Match[dot_pair[i]] = 1;}double aver = sum / n;//printf("aver = %.0lf\n", aver);    int i = 0;for(i = 0; i < n; i++) {double a = 2 * aver - dot_pair[i].first;double b = dot_pair[i].second;LL tmp_pair(a, b);//printf("i = %d : (%.0lf, %.0lf)  (%.0lf, %.0lf)\n", i, dot_pair[i].first, dot_pair[i].second, tmp_pair.first, tmp_pair.first);if(!Match.count(tmp_pair)) break;  }puts(i == n ? "YES" : "NO");}    return 0;}/*35-2 50 06 54 02 342 30 44 00 045 146 105 106 14*/

原创粉丝点击