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;
    }
  • 相关阅读:
    通过Powershell开启RDP
    映射网络驱动器
    简易图书管理系统
    使用IDEA快速创建Spring Boot项目
    oracle11g安装步骤详细图文教程
    使用JDOM创建XML文档
    使用JDOM解析XML文档
    HTML+CSS之金立官网部分实现
    webstorm2019安装与使用详细教程
    第二章 JavaScript基础指令
  • 原文地址:https://www.cnblogs.com/kirito520/p/6211056.html
Copyright © 2011-2022 走看看