-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathabc168-c.rs
34 lines (30 loc) · 1.05 KB
/
abc168-c.rs
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
// https://atcoder.jp/contests/abc168/tasks/abc168_c
//
// 以下のクレートを使用。
// - `num`
// - `num-complex`
// - `proconio`
use num::Complex;
use proconio::input;
use std::f64::consts::PI;
fn main() {
// `proconio::input!`。
//
// https://docs.rs/proconio/0.3.6/proconio/macro.input.html
input! {
a: f64,
b: f64,
h: f64,
m: f64,
}
// 座標として`num_complex::Complex<f64>`を使う。
// `Complex::from_polar`でxとθから(x・cosθ, x・sinθ)を得ることができ、また`Complex::norm`で2点間の距離を出すことができる。
//
// https://docs.rs/num-complex/0.2.4/num_complex/struct.Complex.html
// https://docs.rs/num-complex/0.2.4/num_complex/struct.Complex.html#method.from_polar
// https://docs.rs/num-complex/0.2.4/num_complex/struct.Complex.html#method.norm
let p1 = Complex::from_polar(&a, &(h * PI / 6.0 + m * PI / 360.0));
let p2 = Complex::from_polar(&b, &(m * PI / 30.0));
let ans = (p1 - p2).norm();
println!("{}", ans);
}