結果

問題 No.2811 Calculation Within Sequence
ユーザー sakikuroesakikuroe
提出日時 2024-07-19 21:59:01
言語 Rust
(1.77.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,373 bytes
コンパイル時間 29,486 ms
コンパイル使用メモリ 379,344 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-07-23 19:10:06
合計ジャッジ時間 21,123 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 25 ms
8,960 KB
testcase_04 AC 26 ms
8,960 KB
testcase_05 AC 26 ms
8,832 KB
testcase_06 AC 26 ms
8,960 KB
testcase_07 AC 25 ms
8,960 KB
testcase_08 AC 25 ms
8,960 KB
testcase_09 AC 26 ms
8,960 KB
testcase_10 AC 25 ms
8,960 KB
testcase_11 AC 25 ms
8,960 KB
testcase_12 AC 25 ms
8,960 KB
testcase_13 AC 25 ms
8,960 KB
testcase_14 AC 25 ms
8,960 KB
testcase_15 AC 25 ms
8,960 KB
testcase_16 AC 25 ms
8,960 KB
testcase_17 AC 24 ms
8,960 KB
testcase_18 AC 26 ms
8,960 KB
testcase_19 AC 25 ms
9,088 KB
testcase_20 AC 25 ms
8,960 KB
testcase_21 AC 26 ms
8,960 KB
testcase_22 AC 23 ms
9,088 KB
testcase_23 AC 26 ms
9,344 KB
testcase_24 AC 16 ms
6,944 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 6 ms
6,944 KB
testcase_27 AC 16 ms
6,944 KB
testcase_28 AC 3 ms
6,944 KB
testcase_29 AC 12 ms
6,940 KB
testcase_30 AC 12 ms
6,940 KB
testcase_31 AC 13 ms
6,944 KB
testcase_32 AC 4 ms
6,944 KB
testcase_33 AC 11 ms
6,940 KB
testcase_34 AC 14 ms
6,944 KB
testcase_35 AC 7 ms
6,940 KB
testcase_36 AC 13 ms
6,940 KB
testcase_37 AC 10 ms
6,944 KB
testcase_38 AC 9 ms
6,940 KB
testcase_39 AC 10 ms
6,944 KB
testcase_40 AC 14 ms
6,944 KB
testcase_41 AC 15 ms
6,940 KB
testcase_42 AC 7 ms
6,944 KB
testcase_43 AC 10 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use anmitsu::number_theory::gcd;
use proconio::{fastout, input};

pub mod anmitsu {
    pub mod number_theory {
        /// Returns:
        ///     gcd(a, b)
        ///
        /// Note:
        ///     gcd(0, 0) = 0
        ///     gcd(a, 0) = a
        ///     gcd(a, b) >= 0
        ///     gcd(a, a) == abs(a)
        ///     gcd(a, b) == gcd(b, a)
        ///
        /// Complexity:
        ///     O(log(min(abs(a), abs(b))))
        ///
        /// Exsamples:
        /// ```
        /// use anmitsu::math::number_theory::gcd;
        /// assert_eq!(gcd(0, 0), 0);
        /// assert_eq!(gcd(0, 1), 1);
        /// assert_eq!(gcd(4, 6), 2);
        /// assert_eq!(gcd(4, -6), 2);
        /// assert_eq!(gcd(-4, 6), 2);
        /// assert_eq!(gcd(-4, -6), 2);
        /// assert_eq!(gcd(2, 2), 2);
        /// assert_eq!(gcd(-2, -2), 2);
        /// ```
        pub fn gcd(mut a: i64, mut b: i64) -> u64 {
            while b != 0 {
                (a, b) = (b, a % b);
            }
            a.unsigned_abs()
        }
    }
}

#[fastout]
fn main() {
    input! {
        a: usize, b: usize,
        t: [usize; a],
        s: [usize; b],
    }

    let mut g = t[0];
    for i in 1..a {
        g = gcd(g as i64, t[i] as i64) as usize;
    }

    if s.iter().cloned().any(|x| x % g != 0) {
        println!("No");
    } else {
        println!("Yes");
    }
}
0