ural 2032 Conspiracy Theory and Rebranding (数学水题)
ural 2032 Conspiracy Theory and Rebranding
链接:http://acm.timus.ru/problem.aspx?space=1&num=2032
题意:给定一个三角形的三条边 (a, b, c),问是否可放在二维坐标,使得3个顶点都是整数点。若可以,输出任意一组解,否则,输出 -1。
思路:暴力枚举:以 a 为半径做第一象限的 1/4 圆, 以 b 为半径做 一、四 象限的半圆,存储整数点的解,暴力枚举 a 整数点与 b 整数点是否构成长度为 c 的边。
代码:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cmath> 5 #include <cstring> 6 7 using namespace std; 8 typedef long long ll; 9 const int N = 1e5+7; 10 ll biao[N]; 11 ll a, b, c; 12 int n; 13 14 ll rr, RR; 15 16 struct P{ 17 ll x, y; 18 P(ll _x=0, ll _y=0) : x(_x), y(_y) {} 19 void out() {printf("%I64d %I64d\n", x, y); } 20 }p[N], v[N]; 21 int ta, tb; 22 23 inline ll sqr(ll x) {return x*x;} 24 25 inline void init(ll av, ll r, int &t, P q[]) { 26 ll aa = av*av; 27 for(ll i = 0, j = av; i <= av; ++i) { 28 while(sqr(i) + sqr(j) > aa) --j; 29 if(sqr(i) + sqr(j) == aa) q[t++] = P(i, j); 30 } 31 } 32 33 inline ll dis(P d1, P d2) { 34 return sqr(d1.x - d2.x) + sqr(d1.y - d2.y); 35 } 36 37 void solve() { 38 ta = tb = 0; 39 ll cc = c*c; 40 init(a, rr, ta, p); 41 init(b, RR, tb, v); 42 bool f = 0, ff; 43 int i, j; 44 P q; 45 for(i = 0; i < ta; ++i) { 46 for(j = 0; j < tb; ++j) { 47 ll d = dis(p[i], v[j]); 48 if(d == cc) { 49 f = 1, ff = 0; 50 break; 51 } else{ 52 q = P(v[j].x, -v[j].y); 53 d = dis(p[i], q); 54 if(d == cc) { 55 f = ff = 1; 56 break; 57 } 58 } 59 } 60 if(f) break; 61 } 62 if(!f) { puts("-1"); return ; } 63 puts("0 0"); p[i].out(); 64 if(!ff) v[j].out(); 65 else q.out(); 66 return ; 67 } 68 69 int main() 70 { 71 #ifdef PIT 72 freopen("i.in", "r", stdin); 73 #endif // PIT 74 75 while(~scanf("%I64d %I64d %I64d", &a, &b, &c)) { 76 rr = a*a, RR = b*b; 77 solve(); 78 } 79 return 0; 80 }
转载于:https://www.cnblogs.com/Duahanlang/p/4123429.html
ural 2032 Conspiracy Theory and Rebranding (数学水题)相关推荐
- ural 2032 Conspiracy Theory and Rebranding 整点三角形
ural 2032 Conspiracy Theory and Rebranding 链接:https://vjudge.net/contest/175269#problem/I 题意:给定一个三角形 ...
- URAL 2032 - Conspiracy Theory and Rebranding【本源勾股数组】
[题意] 给出三角形的三个边长,均是10^7以内的整数,问三角形的三个角的坐标是否能均是整数,输出其中任意一个解. [题解] 一开始想的是枚举一条边的横坐标,然后通过勾股定理以及算角度求出其他点的坐标 ...
- UVA10751 Chessboard【数学水题】
A king wishes to go for a walk of a square chessboard with the following conditions: • Each two cons ...
- Ural 1558 - Periodical Numbers 写吐的水题...
题意: (abc)代表abc无穷的循环....问(a1a2a3....)+(b1b2b3...)的值是多少..表示为(...)**的形式(前面是循环的..后面小段不循环的) 题解 练习赛的时候想得有点 ...
- DFS水题 URAL 1152 False Mirrors
题目传送门 1 /* 2 题意:一个圈,每个点有怪兽,每一次射击能消灭它左右和自己,剩余的每只怪兽攻击 3 搜索水题:sum记录剩余的攻击总和,tot记录承受的伤害,当伤害超过ans时,结束,算是剪枝 ...
- 【HDU - 5585】Numbers (水题,数学,数论)
题干: There is a number N.You should output "YES" if N is a multiple of 2, 3 or 5,otherwise ...
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题
B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...
- HDU2086 A1 = ?【水题】
A1 = ? Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- (中石油七)问题 J: 位置2016(水题)
问题 J: 位置2016 题目描述 由于晨晨还没有研究出核心算法,在游戏中总是被明明击败.晨晨拿出了杀手锏进行反击,精心设计了一个数学难题: N个地砖,每个上面写有一个编号,开始这些编号从左到右正好是 ...
最新文章
- Word自定义多级符号方法
- python中def fun(a、b=200)_python 基础 函数
- installshield 脚本 在卸载过程执行_Linux下运行Jmeter脚本
- Golang中unsafe.Sizeof()的问题
- UML---StarUML破解与使用
- 拓端tecdat|R语言解释生存分析中危险率和风险率的变化
- Windows 7的上帝模式
- 数学建模学习:蒙特卡洛模拟
- 内存和flash区别
- phpstudy使用教程(一)
- php源雄武,8个新鲜的PHP常用代码
- 利用极域电子教室控制别人电脑
- 迪文屏中关于MODBUS的接口配置
- Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.supp
- 将图片转换成caffe的数据格式
- Driver/library version mismatch
- 处理数据库镜像问题的一个案例——数据库主体与镜像断开连接
- DSP TMS320C5509A 控制DDS AD9854芯片进行AM幅度调制时的噪声抑制
- 小程序数据获取限制问题解决
- linux文件重命名命令