zoukankan      html  css  js  c++  java
  • Codeforces Round #388 (Div. 2)

    题目链接:http://codeforces.com/contest/749/problem/B

    题意:给定平行四边形的3个点,输出所有可能的第四个点。

    思路:枚举任意两个点形成的直线,然后利用这两个点计算偏移量用第三点求出第四个点。

    #define _CRT_SECURE_NO_DEPRECATE
    #include<iostream>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<stdio.h>
    #include<queue>
    #include<vector>
    #include<stack>
    #include<map>
    #include<set>
    #include<time.h>
    #include<cmath>
    using namespace std;
    typedef long long int LL;
    int main(){
    //#ifdef kirito
    //    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
    //#endif
    //    int start = clock();
        pair<int, int>point[4];
        while (scanf("%d %d", &point[1].first,&point[1].second) != EOF){
            scanf("%d %d", &point[2].first, &point[2].second);
            scanf("%d %d", &point[3].first, &point[3].second);
            set<pair<int, int>>ans;
            for (int i = 1; i <= 3; i++){
                for (int j = i + 1; j <= 3; j++){
                    pair<int, int>p4;
                    int k = 6 - i - j; //非i,j的点
                    int dx = point[i].first - point[j].first;
                    int dy = point[i].second - point[j].second;
                    p4.first = point[k].first + dx;
                    p4.second = point[k].second + dy;
                    ans.insert(p4);
                    
                    p4.first = point[k].first - dx;
                    p4.second = point[k].second - dy;
                    ans.insert(p4);
                }
            }
            printf("%d
    ", ans.size());
            for (set<pair<int,int>>::iterator it=ans.begin(); it!= ans.end(); it++){
                printf("%d %d
    ", it->first, it->second);
            }
        }
    //#ifdef LOCAL_TIME
    //    cout << "[Finished in " << clock() - start << " ms]" << endl;
    //#endif
        return 0;
    }
  • 相关阅读:
    nvidia tx1使用记录--基本环境搭建
    STL hashtable阅读记录
    Linux strace命令
    转一篇:Reactor模式
    C++ 模板特化以及Typelist的相关理解
    C++ 内联函数inline
    迭代器失效的几种情况总结
    C++ Class与Struct的区别
    C++中string.find()函数,string.find_first_of函数与string::npos
    C/C++ 中长度为0的数组
  • 原文地址:https://www.cnblogs.com/kirito520/p/6211056.html
Copyright © 2011-2022 走看看