Created
February 16, 2023 07:19
-
-
Save modos/cf15c13286b21269160300a8611e349a to your computer and use it in GitHub Desktop.
سهتایی فیثاغورثی
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
void pythagoreanTriplet(int n) | |
{ | |
for (int i = 1; i <= n / 3; i++) | |
{ | |
for (int j = i + 1; j <= n / 2; j++) | |
{ | |
int k = n - i - j; | |
if (i * i + j * j == k * k) | |
{ | |
cout << i << " " | |
<< j << " " | |
<< k; | |
return; | |
} | |
} | |
} | |
cout << "Impossible"; | |
} | |
int main() | |
{ | |
int n; | |
cin >> n; | |
pythagoreanTriplet(n); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment