Submission #1694974


Source Code Expand

fn main() {
  let (a, b, c): (f64, f64, f64) = get::read_3tuple();
  
  let f = |t| a * t + b * f64::sin(c * t * std::f64::consts::PI);
  
  let mut tmin = 0.0;
  let mut tmax = 1e9;
  let mut tmed = (tmin + tmax) / 2.0;
  for _ in 0 .. 100 {
    if f(tmed) > 100.0 {
      tmax = tmed;
      tmed = (tmin + tmax) / 2.0;
    } else {
      tmin = tmed;
      tmed = (tmin + tmax) / 2.0;
    }
  }
  
  println!("{}", tmed);
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn read<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    buf.trim().parse::<T>().ok().unwrap()
  }

  pub fn reads<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(read());
    }
    vec
  }

  pub fn read_tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let mut it = buf.trim().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn read_tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(read_tuple());
    }
    vec
  }

  pub fn read_3tuple<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let mut it = buf.trim().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn read_3tuples<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(read_3tuple());
    }
    vec
  }

  pub fn read_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn read_mat<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(read_vec());
    }
    mat
  }
}

Submission Info

Submission Time
Task D - 高橋君ボール1号
User aimy
Language Rust (1.15.1)
Score 100
Code Size 2367 Byte
Status AC
Exec Time 5 ms
Memory 4476 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 17
Set Name Test Cases
Sample example_0.txt, example_1.txt
All example_0.txt, example_1.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, special_0.txt, special_1.txt, special_2.txt, example_0.txt, example_1.txt
Case Name Status Exec Time Memory
example_0.txt AC 5 ms 4476 KB
example_1.txt AC 3 ms 4352 KB
random_0.txt AC 2 ms 4352 KB
random_1.txt AC 2 ms 4352 KB
random_2.txt AC 3 ms 4352 KB
random_3.txt AC 3 ms 4352 KB
random_4.txt AC 2 ms 4352 KB
random_5.txt AC 2 ms 4352 KB
random_6.txt AC 3 ms 4352 KB
random_7.txt AC 3 ms 4352 KB
random_8.txt AC 3 ms 4352 KB
random_9.txt AC 3 ms 4352 KB
special_0.txt AC 3 ms 4352 KB
special_1.txt AC 3 ms 4352 KB
special_2.txt AC 2 ms 4352 KB