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\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【打表】的更多相关文章
- Greeting Card
问题 G: Greeting Card 时间限制: 1 Sec 内存限制: 128 MB 提交: 666 解决: 59 [提交] [状态] [命题人:admin] 题目描述 Quido plans ...
- upc组队赛15 Supreme Number【打表】
Supreme Number 题目链接 题目描述 A prime number (or a prime) is a natural number greater than 1 that cannot ...
- upc组队赛1 过分的谜题【找规律】
过分的谜题 题目描述 2060年是云南中医学院的百年校庆,于是学生会的同学们搞了一个连续猜谜活动:共有10个谜题,现在告诉所有人第一个谜题,每个谜题的答案就是下一个谜题的线索....成功破解最后一个谜 ...
- upc组队赛1 不存在的泳池【GCD】
不存在的泳池 题目描述 小w是云南中医学院的同学,有一天他看到了学校的百度百科介绍: 截止到2014年5月,云南中医学院图书馆纸本藏书74.8457万册,纸质期刊388种,馆藏线装古籍图书1.8万册, ...
- upc组队赛18 THE WORLD【时间模拟】
THE WORLD 题目链接 题目描述 The World can indicate world travel, particularly on a large scale. You mau be l ...
- upc 组队赛18 STRENGTH【贪心模拟】
STRENGTH 题目链接 题目描述 Strength gives you the confidence within yourself to overcome any fears, challeng ...
- upc组队赛3 Chaarshanbegaan at Cafebazaar
Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...
- upc组队赛1 黑暗意志【stl-map】
黑暗意志 题目描述 在数千年前潘达利亚从卡利姆多分离之时,迷雾笼罩着这块新形成的大陆,使它不被外来者发现.迷雾同样遮蔽着这片大陆古老邪恶的要塞--雷神的雷电王座.在雷神统治时期,他的要塞就是雷电之王力 ...
- upc组队赛1 闪闪发光 【优先队列】
闪闪发光 题目描述 一所位于云南昆明的中医药本科院校--云南中医学院. 因为报考某专业的人数骤减,正面临着停招的危机. 其中有九名少女想到一条妙计--成为偶像, 只要她们成为偶像,学校的名气便会增加, ...
随机推荐
- Python中生成器和yield语句的用法详解
Python中生成器和yield语句的用法详解 在开始课程之前,我要求学生们填写一份调查表,这个调查表反映了它们对Python中一些概念的理解情况.一些话题("if/else控制流" ...
- linux的echo命令整理
linux的echo命令, 在shell编程中极为常用, 在终端下打印变量value的时候也是常常用到的, 因此有必要了解下echo的用法 echo命令的功能是在显示器上显示一段文字,一般起到一个提示 ...
- appium报错及解决方案
[已解决]mac上手动打开appium报错:“Could not find aapt Please set the ANDROID_HOME environment variable with the ...
- layer子窗口赋值给父窗口
子窗体赋值给父窗体: parent.$('#Receiver').val(typearr); //关闭子弹窗 var index = parent.layer.getFrameIndex(window ...
- vue-router 传递参数的几种方式
本文转载自:https://blog.csdn.net/crazywoniu/article/details/80942642 vue-router传递参数分为两大类 编程式的导航 router.pu ...
- VB - 错误处理
1.最常见的错误是运行时错误,也就是说错误在脚本正在运行的时候发生,是脚本试图进行非法操作的结果.例如零被作为除数.在vbs中,任何运行时错误都是致命的,此时,脚本将停止运行,并在屏幕上显示一个错误消 ...
- Cocos2d-x打包安卓apk
| 版权声明:本文为博主原创文章,未经博主允许不得转载. 1. 下载安装安卓(android)环境 见http://www.cnblogs.com/geore/p/5793620.html,按照其 ...
- mysql 性能调优 参数随写
set global innodb_buffer_pool_size = 12*1024*1024*1024;set global bulk_insert_buffer_size = 12582912 ...
- 【题解】A Horrible Poem
题目大意 给出一个由小写英文字母组成的字符串 S,再给出 q 个询问,要求回答 S 某个子串的最短循环节. 如果字符串 B 是字符串 A 的循环节,那么 A 可以由 B 重复若干次得到. 输入格式 第 ...
- python基础----求水仙花数
水仙花数,即一个三位数,各个位上的数字的三次方相加,等于该数本身.如:153 = 1**3 + 5 ** 3 + 3 ** 3 def is_narc_num(n): # if n <100 o ...