結果

問題 No.40 多項式の割り算
ユーザー phspls
提出日時 2020-05-23 23:03:17
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 13,446 ms
コンパイル使用メモリ 386,992 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-09 10:37:47
合計ジャッジ時間 15,148 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut d = String::new();
    std::io::stdin().read_line(&mut d).ok();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let mut a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    while a.len() > 3 {
        let val: isize = a.pop().unwrap();
        let pos = a.len()-2;
        a[pos] += val;
    }
    if a.len() == 3 && a[2] == 0 {
        a.pop();
        if a[1] == 0 { a.pop(); }
    }
    println!("{}", a.len() - 1);
    println!("{}", a.iter().map(|i| i.to_string()).collect::<Vec<String>>().join(" "));
}
0