結果

問題 No.2821 A[i] ← 2A[j] - A[i]
ユーザー 37kt37kt
提出日時 2024-08-08 15:00:43
言語 Rust
(1.77.0)
結果
AC  
実行時間 414 ms / 1,500 ms
コード長 416 bytes
コンパイル時間 13,241 ms
コンパイル使用メモリ 378,020 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-08-08 15:01:05
合計ジャッジ時間 21,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 378 ms
6,272 KB
testcase_02 AC 401 ms
8,704 KB
testcase_03 AC 414 ms
8,320 KB
testcase_04 AC 235 ms
6,144 KB
testcase_05 AC 239 ms
5,888 KB
testcase_06 AC 142 ms
5,376 KB
testcase_07 AC 136 ms
5,376 KB
testcase_08 AC 210 ms
5,632 KB
testcase_09 AC 65 ms
5,376 KB
testcase_10 AC 69 ms
5,376 KB
testcase_11 AC 67 ms
5,376 KB
testcase_12 AC 68 ms
5,376 KB
testcase_13 AC 69 ms
5,376 KB
testcase_14 AC 90 ms
5,376 KB
testcase_15 AC 94 ms
5,376 KB
testcase_16 AC 50 ms
5,376 KB
testcase_17 AC 82 ms
5,376 KB
testcase_18 AC 88 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 8 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use proconio::{
    input,
    marker::{Bytes, Chars, Usize1},
};

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut g = 0;
    for i in 0..n {
        if i > 0 {
            g = gcd(g, (a[i - 1] - a[i]).abs());
        }
        println!("{}", g);
    }
}
0