Menu
Coddy logo textTech

Right angle triangle

Coddyの「数学パズル」コースのレッスン 16/20。

ピタゴラスの三つ組 {a, b, c} は直角三角形を形成します。 

各辺の長さが整数である直角三角形 {a, b, c} の周囲の長さ p は、その和 p = a+b+c です。

例:

  • p = 12 のときの {3, 4, 5}、
  • p = 120 のときの {30, 40, 50}, {20, 48, 52}, {24, 45, 51}。
challenge icon

チャレンジ

中級

a + b + c = 1000 を満たすピタゴラスの三つ組は、ただ一つ存在します。

この三つ組をリストとして返す関数 calcSpecialPythagoreanTriplet を作成してください。

自分で試してみよう

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "solution.h"

int main() {
    int rs = 0;
    int* r = calcSpecialPythagoreanTriplet(&rs);
    for (int i = 0; i < rs; i++) {
        if (i > 0) printf(" ");
        printf("%d", r[i]);
    }
    printf("\n");
    return 0;
}

数学パズルのすべてのレッスン

5Diophantine Equation

IntroductionA problem

8Pythagorean triplet

IntroductionRight angle triangleCounting