結果
問題 | No.1319 最強とんがりコーン |
ユーザー |
|
提出日時 | 2023-08-28 10:51:51 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,658 bytes |
コンパイル時間 | 12,267 ms |
コンパイル使用メモリ | 399,748 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-29 08:51:42 |
合計ジャッジ時間 | 17,659 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 64 |
ソースコード
#[allow(unused_imports)]use std::cmp::*;#[allow(unused_imports)]use std::collections::*;use std::io::Read;fn get_word() -> String {let stdin = std::io::stdin();let mut stdin=stdin.lock();let mut u8b: [u8; 1] = [0];loop {let mut buf: Vec<u8> = Vec::with_capacity(16);loop {let res = stdin.read(&mut u8b);if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {break;} else {buf.push(u8b[0]);}}if buf.len() >= 1 {let ret = String::from_utf8(buf).unwrap();return ret;}}}fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }// Intersection of// - 0 <= z <= 1// - x^2 + y^2 <= (1-z)^2// - (x-a)^2 + y^2 <= (1-z)^2// When cut x = b (a/2 <= b <= 1), the area is sqrt(1-b^2) - b^2 ln((1+sqrt(1-b^2))/b)fn calc(a: f64) -> f64 {const W: i64 = 1_000_000;let mut ans = 0.0;let width = 1.0 / W as f64;for i in 0..W + 1 {let b = 1.0 - (1.0 - a / 2.0) * i as f64 * width;let tmp = if b == 0.0 {1.0} else {(1.0 - b * b).sqrt() - b * b * ((1.0 + (1.0 - b * b).sqrt()) / b).ln()};if i % 2 == 1 {ans += tmp * 4.0;} else if i != 0 && i != W {ans += tmp * 2.0;} else {ans += tmp;}}ans * width * 2.0 / 3.0}fn main() {eprintln!("{:?}", calc(0.0));eprintln!("{:?}", calc(2.0));let r: f64 = get();let h: f64 = get();let d: f64 = get();println!("{}", r * r * h * calc(d / r));}