結果

問題 No.959 tree and fire
ユーザー phsplsphspls
提出日時 2020-01-08 18:45:55
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 13,542 ms
コンパイル使用メモリ 382,840 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 13:02:00
合計ジャッジ時間 12,801 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 0 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 0 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 0 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 0 ms
5,376 KB
testcase_37 AC 0 ms
5,376 KB
testcase_38 AC 0 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 1 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 1 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
testcase_53 AC 0 ms
5,376 KB
testcase_54 AC 1 ms
5,376 KB
testcase_55 AC 1 ms
5,376 KB
testcase_56 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn solve(nm: Vec<u64>, p: f64) {
    let n = nm[0];
    let m = nm[1];
    if n > 1 && m > 1 {
        let corners: f64 = 4f64 * p * (p * p);
        let edges: f64 = (((2*n + 2*m) as f64) - 8f64) * p * (p * p * p);
        let inners: f64 = (((n - 2) * (m - 2)) as f64) * p * (p * p * p * p);
        println!("{}", corners + edges + inners);
    } else if n > 1 || m > 1 {
        let corners: f64 = 2f64 * p * (p);
        let edges: f64 = (((n * m) as f64) - 2f64) * p * (p * p);
        println!("{}", corners + edges);
    } else {
        println!("{}", p);
    }
}

fn main() {
    let mut all_data = String::new();
    std::io::stdin().read_to_string(&mut all_data).ok();
    let all_data: Vec<&str> = all_data.trim().split('\n').map(|s| s.trim()).collect();
    let nm: Vec<u64> = all_data.iter().next().unwrap().split_whitespace().map(|b| b.parse::<u64>().unwrap()).collect();
    let p: f64 = all_data.iter().skip(1).next().unwrap().parse::<f64>().unwrap();
    solve(nm, p);
}
0