zoukankan      html  css  js  c++  java
  • Codeforces Round #618 (Div. 1)B(几何,观察规律)

    观察猜测这个图形是中心对称图形是则YES,否则NO

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 pair<long long,long long>pr[100007];
     5 int main(){
     6     ios::sync_with_stdio(false);
     7     cin.tie(NULL);
     8     cout.tie(NULL);
     9     int n;
    10     cin>>n;
    11     for(int i=1;i<=n;++i){
    12         cin>>pr[i].first>>pr[i].second;
    13         pr[i].first=2*pr[i].first;
    14         pr[i].second=2*pr[i].second;
    15     }
    16     if(n%2==1){//奇数点旋转180°一定不对称
    17         cout<<"NO";
    18         return 0;
    19     }
    20     pair<long long,long long>temp=make_pair((pr[1+n/2].first+pr[1].first)/2,(pr[1+n/2].second+pr[1].second)/2);//找到重心
    21     for(int i=1;i<=n/2;++i){
    22         pair<long long,long long>res=make_pair((pr[i+n/2].first+pr[i].first)/2,(pr[i+n/2].second+pr[i].second)/2);
    23         if(temp.first!=res.first||temp.second!=res.second){//如果重心不在一个点,则不是中心对称图形
    24             cout<<"NO";
    25             return 0;
    26         }
    27     }
    28     cout<<"YES";
    29     return 0;
    30 }
    保持热爱 不懈努力 不试试看怎么知道会失败呢(划掉) 世上无难事 只要肯放弃(划掉)
  • 相关阅读:
    程序片段--2的乘方
    Set、Map集合、栈、队列
    Map迭代(六种)
    Struts2标签--控制标签
    线性表
    数据结构笔记(1)
    spingMVC问题小结
    《浪潮之巅》十四章笔记
    《浪潮之巅》十三章笔记
    《浪潮之巅》十二章笔记
  • 原文地址:https://www.cnblogs.com/ldudxy/p/12292728.html
Copyright © 2011-2022 走看看