結果

問題 No.442 和と積
ユーザー atetubou
提出日時 2019-04-30 13:40:06
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 23,957 ms
コンパイル使用メモリ 395,792 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-29 21:32:27
合計ジャッジ時間 16,137 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();
    b.split_whitespace()
        .map(|x| x.trim().parse::<T>().unwrap())
        .collect()
}

fn gcd(x: u64, y: u64) -> u64 {
    let (x, y) = if x < y { (x, y) } else { (y, x) };
    if x == 0 {
        return y;
    }

    return gcd(x, y % x);
}

fn main() {
    let iv = read::<u64>();
    let a = iv[0];
    let b = iv[1];
    let ag = gcd(a + b, a);
    let bg = gcd(a + b, b);
    println!("{}", ag / gcd(ag, bg) * bg);
}
0