Submission #39092457


Source Code Expand

Copy
use proconio::input;
fn gcd(n: usize, m: usize) -> usize {
if m == 0 {
n
} else {
gcd(m, n % m)
}
}
fn main() {
input! {
n: usize,
k: usize,
a: [usize; n],
};
let max_a = a.iter().copied().max().unwrap();
let mut g = a[0];
for a_i in a.iter().copied().skip(1) {
g = gcd(g, a_i);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
use proconio::input;

fn gcd(n: usize, m: usize) -> usize {
    if m == 0 {
        n
    } else {
        gcd(m, n % m)
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    };
    let max_a = a.iter().copied().max().unwrap();
    let mut g = a[0];
    for a_i in a.iter().copied().skip(1) {
        g = gcd(g, a_i);
    }
    let ans = k <= max_a && k % g == 0;
    println!("{}", if ans { "POSSIBLE" } else { "IMPOSSIBLE" });
}

Submission Info

Submission Time
Task A - Getting Difference
User bouzuya
Language Rust (1.42.0)
Score 300
Code Size 474 Byte
Status AC
Exec Time 20 ms
Memory 3572 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 5 ms 2092 KB
sample_02.txt AC 3 ms 2060 KB
sample_03.txt AC 1 ms 2020 KB
sample_04.txt AC 1 ms 2076 KB
subtask_1_01.txt AC 1 ms 2092 KB
subtask_1_02.txt AC 1 ms 2048 KB
subtask_1_03.txt AC 16 ms 3572 KB
subtask_1_04.txt AC 13 ms 3548 KB
subtask_1_05.txt AC 11 ms 2780 KB
subtask_1_06.txt AC 3 ms 2324 KB
subtask_1_07.txt AC 8 ms 3044 KB
subtask_1_08.txt AC 20 ms 3428 KB
subtask_1_09.txt AC 6 ms 2732 KB
subtask_1_10.txt AC 15 ms 3328 KB
subtask_1_11.txt AC 13 ms 3408 KB


2025-04-09 (Wed)
16:11:22 +00:00