传送门

一句话题意:给出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. IdUDPServer 收到4次重复的数据

    IdUDPServer1->Send(RemoteIP, LabeledEdit2->Text.ToInt(), InText, IndyTextEncoding_UTF8()); 我发给 ...

  2. Mysql 5.8安装报错

    1 mysql安装过程中报下面这个错 解决方法:只要将目录改成反斜杠即可. 2 修改密码错误:ERROR 1064 (42000): You have an error in your SQL syn ...

  3. scala -- 递归 实现 斐波那契函数

    求一个起始为0,1,1,2,3的斐波那契序列 def main(args: Array[String]): Unit = { def fib(n: Int): Int = { if (n == 1) ...

  4. jsp常见的指令总结

    一.三个编译指令 1.page指令: 首先,我们要明确一点就是page指令是一个全局指令,针对当前页面,其次我们再来深挖他的功能,它到底有哪些功能那,在我们程序中起到什么作用??? a.语法结构:&l ...

  5. 重学Java

    Java web 的课程告一段落了 现在我觉得我应该重新学习一下 Java基础  先分享下昨天学习递归后写的两个短短的代码 1.求5的阶乘 package test; public class fiv ...

  6. HP LaserJet MFP M227_M231双面打印

    双面打印设置

  7. CTR点击率预估干货分享

    CTR点击率预估干货分享 http://blog.csdn.net/bitcarmanlee/article/details/52138713

  8. 出现了npm ERR! cb() never called!错误

    执行npm i 命令时,出现了npm ERR! cb() never called!错误 解决方案: 1.首先清除你的npm缓存: sudo npm cache clean -f 一般情况执行完后再试 ...

  9. linux下面得小数计算

    可以通过命令行向awk中传递参数. 这样子传递进去的参数,在awk命令中可以访问.每一项都必须作为单一的一个参数来解释.所以,等号之间不能有空格. 比如说我们传递进去一个学生名字,想查这个学生的得分. ...

  10. Genetics in geographically structured populations: defining, estimating and interpreting FST

    摘要:Wright’s F‑statistics, and especially FST, provide important insights into the evolutionary proce ...