编程介的小学生 2019-12-31 17:54 采纳率: 0.2%
浏览 58

Sticks and Right Triangle

Problem Description
We have a stick with infinite length. Now we want to cut 3 sub-sticks with length x, y, z which is not large than L to form a right triangle. With unknown reasons we assume that x, y, z are all integers and satisfy that x, y, z are all co-primed each other. We want to know how many right triangles are there exist under our constraints

Input
The first line of input is an integer T (T<=5) indicating the number of test cases.
Each case contains a single integer L (L<=1,000,000,000,000).

Output
For each test case output a single integer in one line, indicating the number of right triangles.

Sample Input
1
5

Sample Output
1

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-07-27 11:08
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    # 读取数据
    input = readLines()
    
    for(i in 1:length(input)){
        n = as.integer(input[i][1])
        l = as.integer(input[i][2])
    
        # 判断是否满足条件
        if(l < 4){
            print(0)
        }else{
            ans = 0
            for(x in 1:(l/3)){
                for(y in (x+1):(l/3)){
                    for(z in (y+1):(l/3)){
                        if(x*y*z == l && x+y+z != l){
                            ans += 1
                        }
                    }
                }
            }
    
            print(ans)
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥200 csgo2的viewmatrix值是否还有别的获取方式
  • ¥15 Stable Diffusion,用Ebsynth utility在视频选帧图重绘,第一步报错,蒙版和帧图没法生成,怎么处理啊
  • ¥15 请把下列每一行代码完整地读懂并注释出来
  • ¥15 pycharm运行main文件,显示没有conda环境
  • ¥15 寻找公式识别开发,自动识别整页文档、图像公式的软件
  • ¥15 为什么eclipse不能再下载了?
  • ¥15 编辑cmake lists 明明写了project项目名,但是还是报错怎么回事
  • ¥15 关于#计算机视觉#的问题:求一份高质量桥梁多病害数据集
  • ¥15 特定网页无法访问,已排除网页问题
  • ¥50 如何将脑的图像投影到颅骨上