結果

問題 No.736 約比
ユーザー 特命ログイン特命ログイン
提出日時 2018-09-28 23:14:39
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 12,760 ms
コンパイル使用メモリ 405,972 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 07:20:17
合計ジャッジ時間 14,375 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 65
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{stdin, Read};

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut arr = vec![];
    let mut gcd = 0;
    for _ in 0..n {
        let x = get!();
        arr.push(x);
        if gcd == 0 {
            gcd = x;
        } else {
            let (mut a, mut b) = if x < gcd { (x, gcd) } else { (gcd, x) };
            while a != 0 {
                let t = a;
                a = b % a;
                b = t;
            }
            gcd = b;
        }
    }
    for i in 0..arr.len() {
        if i > 0 { print!(":"); }
        print!("{}", arr[i] / gcd);
    }
    println!();
}
0