博客
关于我
1079 三角形
阅读量:626 次
发布时间:2019-03-13

本文共 1456 字,大约阅读时间需要 4 分钟。

???????????????????ai???????????????????????????????????ai?????????????????????????????ai??????????????????????????????????

????

  • ?????

    • ????????????(a^2 + b^2 = c^2)???c????
    • ??????ai????????????
  • ?????

    • ?ai?????????c????ai????(c^2 = ai^2 + b^2)?
    • ?ai?????????a????ai????(a^2 + b^2 = ai^2)?
  • ?????

    • ???????c?????????b??????
    • ????????a?????????b??????
  • ?????

    • ???????????????????????
    • ???????????
  • ????

    #include 
    #include
    #include
    #include
    #include
    using namespace std;void work(int d) { // ?d??????????c for (int c = d + 1; c <= 2 * d * d; ++c) { int b_sq = c * c - d * d; if (b_sq <= 0) continue; int b = sqrt(b_sq); if (b * b == b_sq && b < c) { cout << c << "," << b << endl; } } // ?d??????????a for (int a = 1; a < d; ++a) { int b_sq = d * d - a * a; if (b_sq <= 0) continue; int b = sqrt(b_sq); if (b * b == b_sq && a > b) { cout << a << "," << b << endl; } } cout << endl;}int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) { int d; cin >> d; work(d); } return 0;}

    ????

  • ?????

    • ??n??????
    • ?????????????d?
  • ????work(d)?

    • ?d?????????????c???b?????????
    • ?d?????????????a???b?????????
  • ?????

    • ???????????????????????
    • ??????????????????
  • ?????

    • ?????????????????
  • ???????????????????????????????????

    转载地址:http://elraz.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现countSetBits设置位的数量算法(附完整源码)
    查看>>
    Objective-C实现currency converter货币换算算法(附完整源码)
    查看>>
    Objective-C实现cycle sort循环排序算法(附完整源码)
    查看>>
    Objective-C实现data transformations数据转换算法(附完整源码)
    查看>>
    Objective-C实现datamatrix二维码识别 (附完整源码)
    查看>>
    Objective-C实现DateToDay 方法算法(附完整源码)
    查看>>
    Objective-C实现DBSCAN聚类算法(附完整源码)
    查看>>
    Objective-C实现DBSCAN聚类算法(附完整源码)
    查看>>
    Objective-C实现decision tree决策树算法(附完整源码)
    查看>>
    Objective-C实现degreeToRadian度到弧度算法(附完整源码)
    查看>>
    Objective-C实现depth first search深度优先搜索算法(附完整源码)
    查看>>
    Objective-C实现DES和3DES加解密算法(附完整源码)
    查看>>