結果

問題 No.2555 Intriguing Triangle
ユーザー ikdikd
提出日時 2023-12-01 13:36:28
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 4,658 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 183,260 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-01 13:42:54
合計ジャッジ時間 1,828 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 WA -
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 WA -
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use scanner::Scanner;
use std::io;

fn main() {
    let mut scanner = Scanner::from(io::stdin().lock());
    let (a, b, c) = scan!((i32, i32, i32), <~ scanner);

    for d in 1..(b + c) {
        for e in 1..(b + c) {
            if d + a + e >= b + c {
                continue;
            }
            // let beta = f64::acos(
            //     f64::from(b.pow(2) + (d + a + e).pow(2) - c.pow(2))
            //         / f64::from(2 * b * (d + a + e)),
            // );
            // let gamma = f64::acos(
            //     f64::from(c.pow(2) + (d + a + e).pow(2) - b.pow(2))
            //         / f64::from(2 * c * (d + a + e)),
            // );
            // let dd = f64::sqrt(f64::from(b.pow(2) + d.pow(2)) - f64::from(2 * b * d) * beta.cos());
            // let ee = f64::sqrt(f64::from(c.pow(2) + e.pow(2)) - f64::from(2 * c * e) * gamma.cos());
            let dd = f64::sqrt(
                f64::from(b.pow(2) + d.pow(2))
                    - f64::from(2 * b * d)
                        * (f64::from(b.pow(2) + (d + a + e).pow(2) - c.pow(2))
                            / f64::from(2 * b * (d + a + e))),
            );
            let ee = f64::sqrt(
                f64::from(c.pow(2) + e.pow(2))
                    - f64::from(2 * c * e)
                        * (f64::from(c.pow(2) + (d + a + e).pow(2) - b.pow(2))
                            / f64::from(2 * c * (d + a + e))),
            );
            let v1 = (f64::from(b).powf(2.0) + dd.powf(2.0) - f64::from(d).powf(2.0))
                / (f64::from(2 * b) * dd);
            let v2 = (f64::from(c).powf(2.0) + ee.powf(2.0) - f64::from(e).powf(2.0))
                / (f64::from(2 * c) * ee);
            if (v1 - v2).abs() < 1e-6 {
                println!("Yes");
                return;
            }
        }
    }

    println!("No");
}

// ✂ --- scanner --- ✂
#[allow(unused)]
mod scanner {
    use std::fmt;
    use std::io;
    use std::str;

    pub struct Scanner<R> {
        r: R,
        l: String,
        i: usize,
    }

    impl<R> Scanner<R>
    where
        R: io::BufRead,
    {
        pub fn new(reader: R) -> Self {
            Self {
                r: reader,
                l: String::new(),
                i: 0,
            }
        }

        pub fn scan<T>(&mut self) -> T
        where
            T: str::FromStr,
            T::Err: fmt::Debug,
        {
            self.skip_blanks();
            assert!(self.i < self.l.len()); // remain some character
            assert_ne!(&self.l[self.i..=self.i], " ");
            let rest = &self.l[self.i..];
            let len = rest
                .find(|ch| char::is_ascii_whitespace(&ch))
                .unwrap_or_else(|| rest.len());
            // parse self.l[self.i..(self.i + len)]
            let val = rest[..len]
                .parse()
                .unwrap_or_else(|e| panic!("{:?}, attempt to read `{}`", e, rest));
            self.i += len;
            val
        }

        pub fn scan_vec<T>(&mut self, n: usize) -> Vec<T>
        where
            T: str::FromStr,
            T::Err: fmt::Debug,
        {
            (0..n).map(|_| self.scan()).collect::<Vec<_>>()
        }

        fn skip_blanks(&mut self) {
            loop {
                match self.l[self.i..].find(|ch| !char::is_ascii_whitespace(&ch)) {
                    Some(j) => {
                        self.i += j;
                        break;
                    }
                    None => {
                        self.l.clear(); // clear buffer
                        let num_bytes = self
                            .r
                            .read_line(&mut self.l)
                            .unwrap_or_else(|_| panic!("invalid UTF-8"));
                        assert!(num_bytes > 0, "reached EOF :(");
                        self.i = 0;
                    }
                }
            }
        }
    }

    impl<'a> From<&'a str> for Scanner<&'a [u8]> {
        fn from(s: &'a str) -> Self {
            Self::new(s.as_bytes())
        }
    }

    impl<'a> From<io::StdinLock<'a>> for Scanner<io::BufReader<io::StdinLock<'a>>> {
        fn from(stdin: io::StdinLock<'a>) -> Self {
            Self::new(io::BufReader::new(stdin))
        }
    }

    #[macro_export]
    macro_rules! scan {
        (( $($t: ty),+ ), <~ $scanner: expr) => {
            ( $(scan!($t, <~ $scanner)),+ )
        };
        ([ $t: tt; $n: expr ], <~ $scanner: expr) => {
            (0..$n).map(|_| scan!($t, <~ $scanner)).collect::<Vec<_>>()
        };
        ($t: ty, <~ $scanner: expr) => {
            $scanner.scan::<$t>()
        };
    }
}
// ✂ --- scanner --- ✂
0