Submission #19519689


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        v: [i32],
    }

    // GCD 度の最大値
    let mut max = -1;

    // GCD 度を最大化する整数
    let mut ans = -1;

    // A_1 〜 A_N の最大値が 1000 なので
    // 2 以上 1000 以下の範囲を調べればよい
    for i in 2..=1000 {
        // GCD 度を計算する
        let mut gcd_ness = 0;
        for a in &v {
            if a % i == 0 {
                gcd_ness += 1;
            }
        }

        // GCD 度の最大値と,
        // そのときの i の値を記録する
        if max < gcd_ness {
            max = gcd_ness;
            ans = i;
        }
    }

    println!("{}", ans);
}

Submission Info

Submission Time
Task B - Almost GCD
User toga57
Language Rust (1.42.0)
Score 200
Code Size 729 Byte
Status AC
Exec Time 8 ms
Memory 2164 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All answer_based_00.txt, answer_based_01.txt, answer_based_02.txt, answer_based_03.txt, answer_based_04.txt, handmade_00.txt, handmade_01.txt, handmade_02.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, same_00.txt, same_01.txt, same_02.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
answer_based_00.txt AC 8 ms 1988 KB
answer_based_01.txt AC 2 ms 2036 KB
answer_based_02.txt AC 2 ms 1964 KB
answer_based_03.txt AC 2 ms 1904 KB
answer_based_04.txt AC 2 ms 2164 KB
handmade_00.txt AC 2 ms 2028 KB
handmade_01.txt AC 3 ms 2124 KB
handmade_02.txt AC 1 ms 2096 KB
random_00.txt AC 3 ms 2136 KB
random_01.txt AC 1 ms 2128 KB
random_02.txt AC 1 ms 2004 KB
random_03.txt AC 3 ms 2088 KB
random_04.txt AC 2 ms 1972 KB
same_00.txt AC 3 ms 2068 KB
same_01.txt AC 2 ms 2124 KB
same_02.txt AC 2 ms 1968 KB
sample_01.txt AC 2 ms 2044 KB
sample_02.txt AC 2 ms 2008 KB
sample_03.txt AC 2 ms 2004 KB