题目连接:https://nanti.jisuanke.com/t/41421

题意:给定三个整数a, b, c,求半径为a、b,圆心坐标为原点的两个同心圆上的整点间的距离为c的点对

题解:推一下圆上的整点坐标,因为点数很少然后暴力地算距离就好了

详见代码注释~

代码:

#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;struct point{ll x, y;point(ll _x = 0, ll _y = 0){x = _x, y = _y;}void print1(){printf("%lld %lld ", x, y);}void print2(){printf("%lld %lld\n", x, y);}bool operator < (const point &other) const {if(x == other.x) return y < other.y;return x < other.x;}bool operator == (const point &other) const {return x == other.x && y == other.y;}
};vector<point>veca, vecb;ll dis(point a, point b){return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
}void solve(ll rr, ll r, ll d, vector<point>&A){for (ll i = 1;i*i<= rr; i++){///枚举rr内的平方数ll t = rr - i*i;ll j = sqrt(t);if(j*j != t) continue;///两个数都应该为平方数if(i >= j) break;///防止重复枚举if(__gcd(i*i, t) == 1){///这样求出来的整点都是第一象限的,然后旋转一下ll x = i*j*d;ll y = sqrt(r*r-x*x);A.pb(point(x, y));A.pb(point(-x, y));A.pb(point(x, -y));A.pb(point(-x, -y));}}
}void deal(vector<point>&A, ll r){///返回半径为r的圆上的整点A.pb(point(0, r));A.pb(point(0, -r));A.pb(point(-r, 0));A.pb(point(r, 0));r <<= 1;for (ll d = 1;d*d <= r; d++){///枚举因子if(r%d != 0) continue;solve(r/d, r>>1, d, A);if(d*d== r) break;solve(d, r>>1, r/d, A);}
}struct node{point A, B;node(point _A, point _B){A = _A; B = _B;}bool operator < (const node &other) const {if(A == other.A) return B < other.B;else return A < other.A;}
};vector<node>ans;int main(){int T;scanf("%d", &T);while(T--){veca.clear();vecb.clear();ans.clear();ll a, b, c;scanf("%lld%lld%lld", &a, &b, &c);deal(veca, a);deal(vecb, b);for(int i = 0; i < veca.size(); i++){for(int j = 0; j < vecb.size(); j++){if(dis(veca[i], vecb[j]) == c*c){ans.pb(node(veca[i], vecb[j]));}}}sort(ans.begin(), ans.end());printf("%d\n", ans.size());for(int i = 0; i < ans.size(); i++){ans[i].A.print1();ans[i].B.print2();}}
}

2019 ICPC 上海网络赛 K. Peekaboo相关推荐

  1. 2019 ICPC 上海站网络赛 K.Peekaboo (圆上整点)

    https://nanti.jisuanke.com/t/41421 题意:给定平面上两个点到原点之间的距离aaa和bbb以及这两点之间的距离ccc,且这两点的坐标均是整数,求该两点可能的坐标,按字典 ...

  2. Peekaboo(2019年上海网络赛K题+圆上整点)

    目录 题目链接 题意 思路 代码 题目链接 传送门 题意 你的位置在\(O(0,0)\),\(A\)的位置为\((x_1,y_1)\),\(B\)的位置为\((x_2,y_2)\),现在已知\(a=O ...

  3. 2019 ACM - ICPC 上海网络赛 E. Counting Sequences II (指数型生成函数)

    繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量题解和代码,题目难度不一定按照题号排序,我会在每道题后面加上题目难度指数(1∼51 \sim 51∼5),以模板题难度 11 ...

  4. 2019 ICPC 南昌网络赛 H. The Nth Item

    2019 ICPC 南昌网络赛 H. The Nth Item 题目大意:已知一个数列F(n): F(0)=0,F(1)=1 F(n)=3∗F(n−1)+2∗F(n−2),(n≥2) ​ 给你一个操作 ...

  5. 2019 ICPC 徐州网络赛 J.Random Access Iterator

    2019 ICPC 徐州网络赛 J.Random Access Iterator 题目大意:给你n个点和n-1条边(树形结构),保证1为根节点,通过以下方式dfs遍历: 询问dfs到最深节点的概率(有 ...

  6. 2019 ICPC 南京网络赛 F Greedy Sequence

    You're given a permutation aa of length nn (1 \le n \le 10^51≤n≤105). For each i \in [1,n]i∈[1,n], c ...

  7. 2019 ICPC南昌网络赛 E题 Magic Master 【双向队列】

    传送门:E.Magic Master John is not only a magic master but also a shuffling master. Famous though he is, h ...

  8. 【计蒜客 - 2019南昌邀请赛网络赛 - K】MORE XOR(数学,找规律,打表)

    Given a sequence of nn numbers a_1, a_2, \cdots, a_na1​,a2​,⋯,an​ and three functions. Define a func ...

  9. 2016 ICPC 北京网络赛 A 恶心模拟 F 循环矩阵,FFT(待补) I 模拟

    2016 ICPC 北京网络赛 A - The Book List 题意:每本书有所属种类,给出原生的存放方式,求按新的方式存放的样子. tags:坑到心态爆炸的题==  直接堆进vector里搞的, ...

最新文章

  1. JS 验证表单不能为空
  2. 关于计算机专业的求职信英文怎么说,计算机求职信范文英文3篇
  3. Exchange安装
  4. 会议室管理系统----MROS
  5. java世博会,反应原生失去的世博会
  6. 玩转 VS Code 专栏
  7. [React Native]StatusBar的使用
  8. mysql中如何复制数据表_MySQL中快速复制数据表方法汇总
  9. ads1115应用电路及驱动程序
  10. 13岁残疾、35岁离异……43岁这年她将和全球最美王妃同台……
  11. 一位老中医的养生忠告
  12. 阿里云大数据+AI技术沙龙上海站回顾 | ​揭秘TPC-DS 榜单第一名背后的强大引擎...
  13. Python 批量给图片添加水印小工具
  14. c语言字符nul,在C++中存储非nul终止的C字符串常量
  15. php 图片上加文字,php使用GD库实现图片上添加文字的方法(代码)
  16. http 304响应的理解
  17. 计算机组成原理有如下c语言程序段,《计算机组成原理》课后题答案 清华大学出版 秦磊华 吴非··...
  18. 如何查看键盘上面的键值?
  19. PCB——功放pcb设计
  20. 在学校的超搞笑也!!!!一定要看阿呵呵

热门文章

  1. 【Visual C++】游戏开发笔记四十三 浅墨DirectX教程十一 为三维世界添彩:纹理映射技术(二)
  2. 如何使用自动化测试进行Android UI测试
  3. data在c语言中的作用,data是什么意思
  4. linux脚本date命令,Shell之date命令用法
  5. 连字符-后首字母的大小写
  6. elementUI组件el-table实现分页、勾选、勾选回显功能
  7. H5案例分享—你的数学是语文老师教的吗?
  8. 关于iphone手机影片预览的格式 转自 我的恩师 郑哥
  9. 电脑硬件知识入门之内存篇
  10. 智能驾驶功能软件平台设计规范 第一部分:系统架构