传送门

一句话题意:给出n,d1,d2" role="presentation" style="position: relative;">n,d1,d2n,d1,d2,需要求出n2" role="presentation" style="position: relative;">n2n2个点使得每两点之间的距离不为d1" role="presentation" style="position: relative;">d1d1或者d2" role="presentation" style="position: relative;">d2d2。

好吧这题第一眼直接暴力建图然后发现时间复杂度上天。显然不能暴力建图,看来d1,d2" role="presentation" style="position: relative;">d1,d2d1,d2应该具有一些奇妙的性质。

那么我们对d1,d2" role="presentation" style="position: relative;">d1,d2d1,d2来进行奇偶分析。

我们让d" role="presentation" style="position: relative;">dd表示两点之间的距离,a" role="presentation" style="position: relative;">aa表示两点之间的横坐标差,b" role="presentation" style="position: relative;">bb表示两点之间的纵坐标差。那么不合法的情况就满足d2=a2+b2" role="presentation" style="position: relative;">d2=a2+b2d2=a2+b2。好的讨论开始。

  • 若d2" role="presentation" style="position: relative;">d2d2是一个奇数,显然a" role="presentation" style="position: relative;">aa和b" role="presentation" style="position: relative;">bb是一奇一偶的,这样的话就可以类似在棋盘上黑白染色一样,只染同一种颜色,然后任意两点间的距离的平方就都是偶数了。
  • 若d2" role="presentation" style="position: relative;">d2d2 mod" role="presentation" style="position: relative;">modmod 4=2" role="presentation" style="position: relative;">4=24=2,可以推出a" role="presentation" style="position: relative;">aa和b" role="presentation" style="position: relative;">bb都是奇数,于是一排染色,一排不染色,这样的话任意a" role="presentation" style="position: relative;">aa,b" role="presentation" style="position: relative;">bb是一奇一偶或者两个偶。
  • 最后一种情况,d2" role="presentation" style="position: relative;">d2d2 mod" role="presentation" style="position: relative;">modmod 4=0" role="presentation" style="position: relative;">4=04=0,这是最不好解决的情况,于是果断将每个2∗2" role="presentation" style="position: relative;">2∗22∗2的格子都缩小成一个格子,然后将d" role="presentation" style="position: relative;">dd缩小一半按前两种情况处理即可(反正题目保证可以找到n∗n" role="presentation" style="position: relative;">n∗nn∗n格子,因此只用缩小一次)。

    代码如下:

#include<bits/stdc++.h>
#define eps 1e-7
using namespace std;
int n,d1,d2,cnt=0;
bool f[1005][1005];
inline void solve(int d){
    int b=0;
    while(!(d%4))d>>=2,++b;
    if(d&1){
        for(int i=0;i<(n<<1);++i)
            for(int j=0;j<(n<<1);++j)
                if(((i>>b)+(j>>b))&1)f[i][j]=true;
        return;
    }
    for(int i=0;i<(n<<1);++i)
        for(int j=0;j<(n<<1);++j)
            if((i>>b)&1)f[i][j]=true;
}
int main(){
    scanf("%d%d%d",&n,&d1,&d2);
    solve(d1),solve(d2);
    for(int i=0;i<(n<<1);++i)
        for(int j=0;j<(n<<1);++j)
            if(cnt<n*n&&!f[i][j])printf("%d %d\n",i,j),++cnt;
    return 0;
}

2018.07.12 atcoder Choosing Points(数学分析好题)的更多相关文章

  1. 2018.07.12 atcoder Go Home(贪心)

    传送门 题意简述:大家在数轴上生活,公司在 s. 班车送所有人回家,有 n 个住处,第 i 个位置在 xi,居住了 pi 的人. 保证 xi 互不相同. 大家⼀起投票向前还是向后,如果票数相同就固定向 ...

  2. China Internet Conference(2018.07.12)

    中国互联网大会 时间:2018.07.12地点:北京国家会议中心

  3. 2018.07.20 atcoder Largest Smallest Cyclic Shift(贪心)

    传送门 题意:给你x个a,y个b,z个c,显然这些字符可以拼成若干字符串,然后求这些字符串中最小表示法表示出来的最大的那一个. 解法:贪心思想,用multiset维护现在拼成的字串,每次取一个最小的和 ...

  4. 「AGC025D」 Choosing Points

    「AGC025D」 Choosing Points 神仙构造题. 首先你会尝试暴力做,先随便选一个点,然后把当前能选得全选上,然后你发现这样样例都过不了. 然后我们可以这样考虑:你把距离为 \(\sq ...

  5. http://www.cnbc.com/2016/07/12/tensions-in-south-china-sea-to-persist-even-after-court-ruling.html

    http://www.cnbc.com/2016/07/12/tensions-in-south-china-sea-to-persist-even-after-court-ruling.html T ...

  6. 2018年12月8日广州.NET微软技术俱乐部活动总结

    吕毅写了一篇活动总结,写得很好!原文地址是:https://blog.walterlv.com/post/december-event-microsoft-technology-salon.html ...

  7. 2018.5.12 storm数据源kafka堆积

    问题现象: storm代码依赖4个源数据topic,2018.5.12上午8点左右开始收到告警短信,源头的4个topic数据严重堆积. 排查: 1.查看stormUI, storm拓扑结构如下: 看现 ...

  8. Artificial Intelligence Computing Conference(2018.09.12)

    时间:2018.09.12地点:北京国际饭店会议中心

  9. China Cloud Computing Conference(2018.07.24)

    时间:2018.07.24地点:北京国家会议中心

随机推荐

  1. 24.OGNL与ValueStack(VS)-集合对象初步

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 首先在LoginAction中增加如下字段并提供相应的get/set方法: ...

  2. Haskell语言学习笔记(57)Parsec(4)

    Parser 类型 data ParsecT s u m a type Parsec s u = ParsecT s u Identity type Parser = Parsec String () ...

  3. 【341】Numpy 相关应用

    Numpy_01 >>> from numpy import pi >>> np.linspace(0, 2, 9) array([0. , 0.25, 0.5 , ...

  4. servlet类

    一.Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口,用户若想用发一个动态web资源(即开发一个Java程序向 ...

  5. 30分钟新手git教程

    本文转载自:http://igeekbar.com/igeekbar/post/82.htm Git近些年的火爆程度非同一般,这个版本控制系统被广泛地用在大型开源项目(比如Linux),不同规模的团队 ...

  6. oracle老是出现监听错误

    解决方法之一: 点击开始-->选择程序--->选中你安装的oracle版本-->选中配置与移植工具-->选中Net Configuration Assistant-->在 ...

  7. oozie错误:javax.servlet.jsp.el.ELException: variable [***] cannot be resolved

    完整错误: javax.servlet.jsp.el.ELException: variable [compute] cannot be resolved at org.apache.oozie.ut ...

  8. proc

    1. /proc 下文件的内容是动态创建的,当文件可写时可用作控制和配置目的. 2. 在某个进程读取 /proc 文件时,内核会分配一个内存页,驱动程序通过这个内存页将数据返回到用户空间 (read( ...

  9. HTTP Response Code 中文详解

      引自:https://blog.csdn.net/lplj717/article/details/70053560   1xx - 信息提示这些状态代码表示临时的响应.客户端在收到常规响应之前,应 ...

  10. Spring ThreadPoolTaskExecutor

    1. ThreadPoolTaskExecutor配置 1 <!-- spring thread pool executor --> 2 <bean id="taskExe ...