首页 > 其他分享 >第六场问题 G: Greeting Card

第六场问题 G: Greeting Card

时间:2023-05-26 15:00:53浏览次数:35  
标签:第六场 int plotter Greeting 1680 2018 20180000 1118 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


一开始思路是暴力,但是想想肯定会超时,这里方法比较像广搜中dir数组的用法,提前暴力计算一下如果两点距离为2018那么这两个点坐标之间的关系,不难得出这样的结论:如果两个点距离为2018 ,那么只能:①x距离差2018,y相等 ②x相等,y差2018 ③x差1680,y差1118 ④x差1118,y差1680。根据这四种情况,选取给的点,然后看看x和y相对位移这样一段距离后的点是否存在,如果存在说明选这两个点符合条件,计数加一。输出时应该除以二因为每条边实际上是计算了两次。
 

#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int maxn = 1e5+3;
typedef pair <ll,ll> pq;
map <pq,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()
{
#ifndef ONLINE_JUDGE
    freopen("in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,ans = 0;
    cin >> n;
    for(int i = 0;i < n; i++)
    {
        ll x,y;
        cin >> x >> y;
        ans += m[{x,y}];
        for(int i = 0;i < 12; i++)
            m[{x + dir[i][0],y + dir[i][1]}]++;
    }
    cout << ans << endl;
    return 0;
}

 

标签:第六场,int,plotter,Greeting,1680,2018,20180000,1118,Card
From: https://blog.51cto.com/u_16131191/6356134

相关文章

  • 第六场问题 F: GlitchBot(模拟)
    传送门题目描述Oneofourdeliveryrobotsismalfunctioning!Thejoboftherobotissimple;itshouldfollowalistofinstructionsinordertoreachatargetdestination.Thelistofinstructionsisoriginallycorrecttogettherobottothetarget.However,......
  • Flex实践——Personal Card制作
    label,text,textInput,button,radioButton,comboBox .     准备工作和上几次描述的一样,新建一个MXMLApplication:PersonalCard      然后拖控件,具体步骤不在这里描述了,都是直接拖控件就能用了,注意给需要操作的控件标上ID     接下来,来看一下comboBox的具......
  • android-card-slide-panel模仿探探首页卡片左右滑动效果,滑动流畅,卡片view无限重生...
    android-card-slide-panel类别: 图像(Image)打分: ★★★★★更新: 2015-12-0312:37大小: 10003kb开发环境: AndroidStudio浏览: 913次下载: 213次项目地址: https://github.com/xmuSistone/android-card-slide-panel图片,手势下载 收藏xmuSistone......
  • Android滑动卡片效果:Swipecards
    一个类似于Tinder的Android库,用于创建滑动卡片效果。您可以向左或向右滑动来切换喜欢或不喜欢的内容。 //implementtheonFlingListenerpublicclassMyActivityextendsActivity{...@OverrideprotectedvoidonCreate(BundlesavedInstanceState){......
  • 「题解」ABC241Ex Card Deck Score
    小时候最喜欢看的一集没有\(b_i\)怎么做?答案是\([x^m]\prod\frac{1}{1-a_ix}\),我们知道它可以分解为\(\sum\frac{R_i}{1-a_ix}\),其中\(R_i\)是一个常数。具体构造就是上面EI的blog,和中国剩余定理及其类似。那么\(R_i=\frac{1-a_ix}{\prod_j(1-a_jx)}\bmod(1-a_ix)\)......
  • CodeForces - 626B Cards (全排列&模拟)
    TimeLimit: 2000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uCodeForces-626BCardsSubmit StatusDescriptionCatherinehasadeckof ntakeanytwo(notnecessarilyadjacent)cardswithdifferentcolorsandexchangethemforanewcardof......
  • 【问题排查篇】一次业务问题对 ES 的 cardinality 原理探究
    作者:京东科技王长春业务问题小编工作中负责业务的一个服务端系统,使用了Elasticsearch服务做数据存储,业务运营人员反馈,用户在使用该产品时发现,用户后台统计的订单笔数和导出的订单笔数不一致!交易订单笔数不对,出现差错订单了?这一听极为震撼!出现这样的问题,在金融科技公司里面是......
  • 多校第六场 1011 hdu 5363Key Set(组合数学)
    题目链接:hdu5363题目大意:给出一个到n的自然数集合,问它有多少个子集,元素之和是偶数。题目分析:首先偶数不会导致集合的和的奇偶性发生变化;奇数会导致集合的和的奇偶性发生变化。我们设奇数m1个,偶数m2个。所以我们可以选取0~m1个偶数,但是只能选取偶数个奇数。那么偶数的方案数就是......
  • LCM Cardinality UVA - 10892
    给出n,求有多少对(a,b)(a<b),满足LCM(a,b)=n 暴力求所有因数#include<iostream>#include<algorithm>#include<vector>usingnamespacestd;constintN=1e4+20;#defineintlonglongconstintinf=1e9;voidsov(intn){ vector<int>v;......
  • abc247_f Cards 题解
    Cards题意有\(N\)张卡片,每张卡片上都写有两个数字,第\(i\)张卡片上的数字分别为\(P_i,Q_i\)。同时,\(P=(P_1,P_2,\dots,P_N)\)和\(Q=(Q_1,Q_2,\dots,Q_N)\)都是\((1,2,\dots,N)\)的全排列。我们需要在\(N\)张卡片中选出一些卡片,并且\(1,2,\dots,N......