-
Notifications
You must be signed in to change notification settings - Fork 0
/
1582.c
52 lines (50 loc) · 768 Bytes
/
1582.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//1582
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void sort(int v[], int len)
{
int i, j, tmp;
for(i=0;i<len-1;i++)
for(j=0;j<len-i-1;j++)
if(v[j]<v[j+1])
{
tmp=v[j];
v[j]=v[j+1];
v[j+1]=tmp;
}
}
int mdc(int a, int b, int c)
{
int aux;
while(a)
{
aux=a;
a=b%a;
b=aux;
}
while(b)
{
aux=b;
b=c%b;
c=aux;
}
return c;
}
int main()
{
int a, b, c, m, n, o, div;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
int v[3]={a,b,c};
sort(v,3);
div = mdc(v[0],v[1],v[2]);
if(pow(v[0],2) == pow(v[1],2) + pow(v[2],2) && div == 1)
printf("tripla pitagorica primitiva\n");
else if(pow(v[0],2) == pow(v[1],2) + pow(v[2],2) && div != 1)
printf("tripla pitagorica\n");
else
printf("tripla\n");
}
return 0;
}