function toSqrt(number) {     // 取平方根    return Math.sqrt(number) } function toPow (number) {     // 求平方    return Math.pow(number, 2) } function toAbs(number) {     // 求绝对值          return Math.abs(number) } var n = readline(); var ans ="NO"; for(let i = 0; i < n; i++){    let linesX = readline().split(" ");    let linesY = readline().split(" ");    var vectorLength = [];    for(let i = 0; i < 4; i++) {         for(let j = 0; j < i; j++) {                          let vector = {                                 x: linesX[j] - linesX[((j+1)%4)],                                  y: linesY[j] - linesY[((j+1)%4)]                          };             let newVectorLength = toSqrt(toPow(vector.x) + toPow(vector.y));             vectorLength.push(newVectorLength);         }    }    vectorLength = vectorLength.sort()    if(vectorLength[0] == vectorLength[3]      && vectorLength[4] == vectorLength[5]      && toAbs(2 * toPow(vectorLength[0]) - toPow(vectorLength[4])) <= Math.pow(1, -10)     ) {         ans ="YES"    }          print(ans) } 之后想到的 js比较暴力的方法 也不知道有没有优化的额
点赞 评论

相关推荐

03-26 15:18
已编辑
华北水利水电大学 Java
点赞 评论 收藏
分享
牛客网
牛客企业服务