結果
問題 | No.2555 Intriguing Triangle |
ユーザー |
|
提出日時 | 2023-12-01 02:10:50 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 4,054 bytes |
コンパイル時間 | 12,004 ms |
コンパイル使用メモリ | 378,688 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 15:29:19 |
合計ジャッジ時間 | 13,102 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#![allow(unused_imports, unused_macros, dead_code)]use std::{cmp::*, collections::*};fn f(a: f64, a1: f64, b: f64, c: f64) -> f64 {let d = a * a + b * b - c * c;let x2 = a1 * a1 + b * b - a1 * d / a;let x = x2.sqrt();b / x - a1 * d / 2.0 / a / b / x}fn main() {let mut sc = Scanner::default();let a: f64 = sc.cin();let b: f64 = sc.cin();let c: f64 = sc.cin();// / \// (b) (c)// / \// B-(a1)-D-(a)-E-(a2)-Clet mut ans = "No";for a1 in 1..=100 {let a1 = a1 as f64;for a2 in 1..=100 {let a2 = a2 as f64;let aa = a1 + a + a2;if aa >= b + c {continue;}if b >= aa + c {continue;}if c >= aa + b {continue;}let t1 = f(aa, a1, b, c);let t2 = f(aa, a2, c, b);if (t1 - t2).abs() < 1e-8 {trace!((a1, a2), (t1, t2));ans = "Yes";break;}}}put!(ans);}// {{{use std::io::{self, Write};use std::str::FromStr;#[derive(Default)]pub struct Scanner {buffer: VecDeque<String>,}impl Scanner {pub fn cin<T: FromStr>(&mut self) -> T {while self.buffer.is_empty() {let mut line = String::new();let _ = io::stdin().read_line(&mut line);self.buffer = line.split_whitespace().map(|w| String::from(w)).collect();}self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()}pub fn usize1(&mut self) -> usize {self.cin::<usize>() - 1}pub fn chars(&mut self) -> Vec<char> {self.cin::<String>().chars().collect()}pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {(0..n).map(|_| self.cin()).collect()}pub fn pair<S: FromStr, T: FromStr>(&mut self) -> (S, T) {(self.cin::<S>(), self.cin::<T>())}}fn flush() {io::stdout().flush().unwrap();}#[macro_export]macro_rules! min {(.. $x:expr) => {{let mut it = $x.iter();it.next().map(|z| it.fold(z, |x, y| min!(x, y)))}};($x:expr) => ($x);($x:expr, $($ys:expr),*) => {{let t = min!($($ys),*);if $x < t { $x } else { t }}}}#[macro_export]macro_rules! max {(.. $x:expr) => {{let mut it = $x.iter();it.next().map(|z| it.fold(z, |x, y| max!(x, y)))}};($x:expr) => ($x);($x:expr, $($ys:expr),*) => {{let t = max!($($ys),*);if $x > t { $x } else { t }}}}#[macro_export]macro_rules! trace {(# $a:ident $(,)? $(;)? $($xs:expr),* $(,)? ) => {#[cfg(debug_assertions)]eprintln!("[{}] {} = {:?}", stringify!($a), stringify!($($xs),*), ($($xs),*))};($($xs:expr),* $(,)?) => {#[cfg(debug_assertions)]eprintln!(">>> {} = {:?}", stringify!($($xs),*), ($($xs),*))};}#[macro_export]macro_rules! put {(# $a:ident) => {println!("{}", stringify!($a))};(.. $x:expr) => {{let mut it = $x.iter();if let Some(x) = it.next() { print!("{}", x); }for x in it { print!(" {}", x); }println!("");}};($x:expr) => { println!("{}", $x) };($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }}#[macro_export]macro_rules! ndarray {($x:expr;) => { $x };($x:expr; $size:expr $( , $rest:expr )*) => {vec![ndarray!($x; $($rest),*); $size]};}/// Array-indexing by i64./// (Vec<Vec<..<T>..>>; i64, i64, ..) => Option<T>#[macro_export]macro_rules! at {($s:expr;) => { Some($s) };($s:expr; $idx:expr $(,$args:expr)* $(,)?) => {if 0 <= $idx {let idx_usize = $idx as usize;if idx_usize < $s.len() {at!($s[idx_usize]; $($args),*)} else {None}} else {None}}}// }}}