https://atcoder.jp/contests/math-and-algorithm/tasks/abc168_c
sin/cosはこんな感じですね。
theta.sin() theta.cos()
// : (Colon) #![allow(non_snake_case)] use std::ops::Sub; use std::f64::consts::PI; //////////////////// library //////////////////// fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } //////////////////// Point //////////////////// #[derive(Clone, Copy)] #[derive(Debug)] struct Point { x: f64, y: f64, } impl Sub for Point { type Output = Self; fn sub(self, other: Self) -> Self { Self { x: self.x - other.x, y: self.y - other.y } } } impl Point { fn inner_product(v: &Point, w: &Point) -> f64 { v.x * w.x + v.y * w.y } fn mag(&self) -> f64 { Point::inner_product(self, self).sqrt() } } //////////////////// process //////////////////// fn read_input() -> (i32, i32, i32, i32) { let v = read_vec(); (v[0], v[1], v[2], v[3]) } fn make_point(L: f64, theta: f64) -> Point { Point { x: -L * theta.sin(), y: L * theta.cos() } } fn f(A: i32, B: i32, H: i32, M: i32) -> f64 { let pt1 = make_point(A as f64, (H as f64 + (M as f64) / 60.0) * PI / 6.0); let pt2 = make_point(B as f64, (M as f64) * PI / 30.0); (pt1 - pt2).mag() } fn main() { let (A, B, H, M) = read_input(); println!("{}", f(A, B, H, M)) }