zoukankan      html  css  js  c++  java
  • upc组队赛6 Greeting Card【打表】

    Greeting Card

    题目描述

    Quido plans to send a New Year greeting to his friend Hugo. He has recently acquired access to an advanced high-precision plotter and he is planning to print the greeting card on the plotter.
    Here’s how the plotter operates. In step one, the plotter plots an intricate pattern of n dots on the paper. In step two, the picture in the greeting emerges when the plotter connects by a straight segment each pair of dots that are exactly 2 018 length units apart.
    The plotter uses a special holographic ink, which has a limited supply.Quido wants to know the number of all plotted segments in the picture to be sure that there is enough ink to complete the job.

    输入

    The first line of input contains a positive integer n specifying the number of plotted points. The following n lines each contain a pair of space-separated integer coordinates indicating one plotted point. Each coordinate is non-negative and less than 231. There are at most 105 points, all of them are distinct.
    In this problem, all coordinates and distances are expressed in plotter length units, the length of the unit in the x-direction and in the y-direction is the same.

    输出

    The output contains a single integer equal to the number of pairs of points which are exactly 2018 length units apart.

    样例输入

    4
    20180000 20180000
    20180000 20182018
    20182018 20180000
    20182018 20182018
    

    样例输出

    4
    

    题意

    给出n个点的坐标,求有多少条长度为2018的线

    题解

    通过打表发现只有 (0,2018) (1118,1680)这两对能构成2018

    可以用map或者set来存

    代码

    #include<bits/stdc++.h>
    using namespace std;
    #define pb push_back
    #define mp make_pair
    #define rep(i,a,n) for(int i=a;i<n;++i)
    #define readc(x) scanf("%c",&x)
    #define read(x) scanf("%d",&x)
    #define sca(x) scanf("%d",&x)
    #define read2(x,y) scanf("%d%d",&x,&y)
    #define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
    #define print(x) printf("%d
    ",x)
    #define mst(a,b) memset(a,b,sizeof(a))
    #define lowbit(x) x&-x
    #define lson(x) x<<1
    #define rson(x) x<<1|1
    #define pb push_back
    #define mp make_pair
    typedef long long ll;
    typedef pair<ll,ll> P;
    const int INF =0x3f3f3f3f;
    const int inf =0x3f3f3f3f;
    const int mod = 1e9+7;
    const int MAXN = 105;
    const int maxn = 10010;
    int n,t;
    map<P,ll> m;
    ll dir[12][2] = {2018,0,0,2018,-2018,0,0,-2018,1118,1680,-1118,1680,1118,-1680,-1118,-1680,1680,1118,1680,-1118,-1680,1118,-1680,-1118};
    int main(){
      sca(t);
      ll x,y;
      ll sum = 0;
      while(t--){
        scanf("%lld%lld",&x,&y);
        sum += m[{x,y}];
        rep(i,0,12){
          m[{x+dir[i][0],y+dir[i][1]}]++;
        }
      }
      printf("%lld
    ",sum);
      return 0;
    }
    
  • 相关阅读:
    (转)游戏设备的三大未来趋势
    (转)零基础学习 Hadoop 该如何下手?
    (转)如何系统地学习数据挖掘?
    (转)大数据最核心的价值是什么?
    (转)面向对象编程的弊端是什么?
    (转)处理器架构、指令集和汇编语言,三者有何关系?
    (转)游戏界人士如何看待《征途》这款游戏?
    (转)想从事游戏开发,1 年内能精通 C++ 吗,还需要学习什么?
    (转)数据库老兵:NewSQL才是未来
    (转)神舟飞船上的计算机使用什么操作系统,为什么是自研发不是 Linux?
  • 原文地址:https://www.cnblogs.com/llke/p/10800103.html
Copyright © 2011-2022 走看看