結果

問題 No.736 約比
コンテスト
ユーザー phspls
提出日時 2020-02-19 22:55:08
言語 Rust
(1.99.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 662 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-09-12 05:09:37
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

use std::cmp::{min, max};

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        return b;
    }
    gcd(b, a % b)
}

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut gcdval: usize = a[0];
    for i in 1..n {
        gcdval = gcd(max(gcdval, a[i]), min(gcdval, a[i]));
    }

    println!("{}", a.iter().map(|i| i / gcdval).map(|i| i.to_string()).collect::<Vec<String>>().join(":"));
}
0