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\n",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\n",sum);
return 0;
}

upc组队赛6 Greeting Card【打表】的更多相关文章

  1. Greeting Card

    问题 G: Greeting Card 时间限制: 1 Sec  内存限制: 128 MB 提交: 666  解决: 59 [提交] [状态] [命题人:admin] 题目描述 Quido plans ...

  2. upc组队赛15 Supreme Number【打表】

    Supreme Number 题目链接 题目描述 A prime number (or a prime) is a natural number greater than 1 that cannot ...

  3. upc组队赛1 过分的谜题【找规律】

    过分的谜题 题目描述 2060年是云南中医学院的百年校庆,于是学生会的同学们搞了一个连续猜谜活动:共有10个谜题,现在告诉所有人第一个谜题,每个谜题的答案就是下一个谜题的线索....成功破解最后一个谜 ...

  4. upc组队赛1 不存在的泳池【GCD】

    不存在的泳池 题目描述 小w是云南中医学院的同学,有一天他看到了学校的百度百科介绍: 截止到2014年5月,云南中医学院图书馆纸本藏书74.8457万册,纸质期刊388种,馆藏线装古籍图书1.8万册, ...

  5. upc组队赛18 THE WORLD【时间模拟】

    THE WORLD 题目链接 题目描述 The World can indicate world travel, particularly on a large scale. You mau be l ...

  6. upc 组队赛18 STRENGTH【贪心模拟】

    STRENGTH 题目链接 题目描述 Strength gives you the confidence within yourself to overcome any fears, challeng ...

  7. upc组队赛3 Chaarshanbegaan at Cafebazaar

    Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...

  8. upc组队赛1 黑暗意志【stl-map】

    黑暗意志 题目描述 在数千年前潘达利亚从卡利姆多分离之时,迷雾笼罩着这块新形成的大陆,使它不被外来者发现.迷雾同样遮蔽着这片大陆古老邪恶的要塞--雷神的雷电王座.在雷神统治时期,他的要塞就是雷电之王力 ...

  9. upc组队赛1 闪闪发光 【优先队列】

    闪闪发光 题目描述 一所位于云南昆明的中医药本科院校--云南中医学院. 因为报考某专业的人数骤减,正面临着停招的危机. 其中有九名少女想到一条妙计--成为偶像, 只要她们成为偶像,学校的名气便会增加, ...

随机推荐

  1. Maximum of lines in a DataBand

    Hello! I have a problem.I have a DataBand, but I need it to grow only up to 14 lines. If it is beyon ...

  2. intel instruction 指令速查

    参考:http://ref.x86asm.net/ http://ref.x86asm.net/coder32.html

  3. Vim使用taglist功能

    下载 wget http://www.vim.org/scripts/download_script.php?src_id=19574 -O taglist.zip 然后解压taglist.zip到~ ...

  4. FWT公式一览

    总表 真值表 对应运算 FWT IFWT A=B=0 A≠B A=B=1 左项 右项 左项 右项 0 0 1 & L+R R L-R R 0 1 0 ^ L+R L-R (L+R)/2 (L- ...

  5. RSTP生成树

    一.实验目的 二.实验拓扑图 三.实验编址 四.实验步骤 1.基本步骤 配置PC机IP 配置完成,开启所有设备,测试主机之间连通性 2.配置RSTP基本功能 在四台交换机上修改生成树模式:配置完成后, ...

  6. fiddler 暂停抓包

    或者点击左下角 capturing

  7. 金额格式化,例子:fmoney("12345.675910", 3),返回12,345.676

    /** * 金额格式化 * 例子:fmoney("12345.675910", 3),返回12,345.676 * @data 备注lhh 2016-09-18 */ functi ...

  8. 详解 CSS 绝对定位

    基本定义和用法 在 CSS 中,position 属性指定一个元素(静态的,相对的,绝对或固定,以及粘性定位)的定位方法的类型. 当设置 position 属性的值为 absolute 时,生成绝对定 ...

  9. kubernetes容器集群管理启动一个测试示例

    创建nginx 创建3个nginx副本 [root@master bin]# kubectl run nginx --image=nginx --replicas=3 kubectl run --ge ...

  10. React-Native初识-安卓篇(一)

    前言:React-Native简称RN,可以用来构建Android和IOS的应用程序,在接下来的两个半月里,我会记录下本人在学习RN开发项目中的点滴. 本篇目录: 1.React-Native初识 2 ...