-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtri.rs
More file actions
30 lines (25 loc) · 674 Bytes
/
tri.rs
File metadata and controls
30 lines (25 loc) · 674 Bytes
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
use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Failed to read line");
let mut l: Vec<i32> = input
.split_whitespace()
.map(|s| s.parse().expect("Failed to parse"))
.collect();
l.sort();
let result = if l[2] >= l[1] + l[0] {
0
} else {
let a_squared = l[0].pow(2);
let b_squared = l[1].pow(2);
let c_squared = l[2].pow(2);
if c_squared == a_squared + b_squared {
1
} else if c_squared > a_squared + b_squared {
2
} else {
3
}
};
println!("{}", result);
}