CodeForces 407A 手速题

//CodeForces 407A

 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "algorithm"
 5 using namespace std;
 6 int square[1010];
 7 struct p
 8 {
 9     int x, y;
10 }A[1010], B[1010];
11 int tot_a, tot_b;
12 int a, b;
13 
14 int main()
15 {
16     int i, j;
17     for(i = 1; i <= 1000; ++i)
18         square[i] = i * i;
19     scanf("%d%d", &a, &b);
20     a *= a;
21     b *= b;
22     tot_a = tot_b = 0;
23     for(i = 1; i <= 1000; ++i) {
24         for(j = 1; j <= i; ++j) {
25             if(square[i] + square[j] == a) {
26                 A[++tot_a].x = i;
27                 A[tot_a].y = j;
28                 A[++tot_a].x = -i;
29                 A[tot_a].y = j;
30                 if(i != j) {
31                     A[++tot_a].x = j;
32                     A[tot_a].y = i;
33                     A[++tot_a].x = -j;
34                     A[tot_a].y = i;
35                 }
36             }
37             if(square[i] + square[j] == b) {
38                 B[++tot_b].x = i;
39                 B[tot_b].y = j;
40                 B[++tot_b].x = -i;
41                 B[tot_b].y = j;
42                 if(i != j) {
43                     B[++tot_b].x = j;
44                     B[tot_b].y = i;
45                     B[++tot_b].x = -j;
46                     B[tot_b].y = i;
47                 }
48             }
49 
50 
51         }
52     }
53     int cx, cy;
54     bool done = 0;
55     for(i = 1; i <= tot_a; ++i) {
56         for(j = 1; j <= tot_b; ++j) {
57             cx = A[i].x - B[j].x;
58             cy = A[i].y - B[j].y;
59             cx *= cx;
60             cy *= cy;
61             if((cx + cy == a + b || cx + cy + a == b || cx + cy + b == a) && A[i].x != B[j].x && A[i].y != B[j].y) {
62                 done = 1;
63                 break;
64             }
65         }
66         if(done)
67             break;
68     }
69     if(done) {
70         printf("YES\n0 0\n%d %d\n%d %d\n", A[i].x, A[i]. y, B[j].x, B[j].y);
71     }
72     else {
73         printf("NO\n");
74     }
75 }

 

转载于:https://www.cnblogs.com/AC-Phoenix/p/4299063.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值