UVa 11479 - Is this the easiest problem?

Contents

  1. 1. Problem
  2. 2. Solution
  3. 3. Code

Problem

題目網址
中文網址

Solution

可先將數字由小排到大,方便待會判斷。

Code

UVa 11479
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
#include<cstdio>

typedef long long LL;
inline void swap(LL &a, LL &b);
int main()
{
int Case;
scanf("%d", &Case);

LL x, y, z;
for (int c = 1; c <= Case; c++)
{
printf("Case %d: ", c);

scanf("%lld%lld%lld", &x, &y, &z);
if (y > x)
swap(x, y);
if (z > x)
swap(x, z);
if (z > y)
swap(y, z);

if (z <= 0 || x >= y + z)
puts("Invalid");
else if (x == y&&y == z)
puts("Equilateral");
else if (x == y || y == z)
puts("Isosceles");
else
puts("Scalene");
}

return 0;
}
void swap(LL &a, LL &b)
{
LL temp = a;
a = b;
b = temp;
}