zoukankan      html  css  js  c++  java
  • 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
    0 0
    %d %d
    %d %d
    ", A[i].x, A[i]. y, B[j].x, B[j].y);
    71     }
    72     else {
    73         printf("NO
    ");
    74     }
    75 }
  • 相关阅读:
    链表首尾节点的常规方案
    MYSQL 学习
    卡尔曼滤波
    降维技术
    Hurst指数python实现
    一维GMM的Python代码实现
    对数周期幂率模型(LPPL)
    paper 112:hellinger distance
    paper 111:图像分类物体目标检测 from RCNN to YOLO
    paper 110:凸优化和非凸优化
  • 原文地址:https://www.cnblogs.com/AC-Phoenix/p/4299063.html
Copyright © 2011-2022 走看看