Submission #15718970


Source Code Expand

Copy
use proconio::input;

fn prime_factorization(n: usize) -> Vec<(usize, usize)> {
    let mut p = vec![];
    if n < 2 {
        return p;
    }
    let mut n = n; // shadowing
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut c = 0;
        while n % i == 0 {
            c += 1;
            n /= i;
        }
        if c > 0 {
            p.push((i, c));
        }
    }
    if n != 1 {
        p.push((n, 1));
    }
    p
}

fn main() {
    input! {
        n: usize,
        p: usize,
    };
    let mut x = 1_usize;
    for (p_i, q_i) in prime_factorization(p) {
        x *= p_i.pow((q_i / n) as u32);
    }
    let ans = x;
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - Product and GCD
User bouzuya
Language Rust (1.42.0)
Score 300
Code Size 694 Byte
Status AC
Exec Time 13 ms
Memory 2124 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 34
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt, sample4.txt
All sample1.txt, sample2.txt, sample3.txt, sample4.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
1.txt AC 9 ms 1976 KB
10.txt AC 4 ms 2068 KB
11.txt AC 2 ms 2124 KB
12.txt AC 2 ms 2108 KB
13.txt AC 2 ms 2124 KB
14.txt AC 2 ms 2016 KB
15.txt AC 3 ms 2024 KB
16.txt AC 2 ms 2096 KB
17.txt AC 9 ms 2028 KB
18.txt AC 2 ms 1904 KB
19.txt AC 2 ms 1980 KB
2.txt AC 2 ms 1904 KB
20.txt AC 2 ms 1968 KB
21.txt AC 3 ms 2060 KB
22.txt AC 2 ms 2088 KB
23.txt AC 13 ms 1992 KB
24.txt AC 2 ms 2052 KB
25.txt AC 2 ms 2104 KB
26.txt AC 2 ms 2036 KB
3.txt AC 2 ms 1980 KB
4.txt AC 3 ms 2004 KB
5.txt AC 2 ms 2112 KB
6.txt AC 2 ms 2052 KB
7.txt AC 2 ms 2072 KB
8.txt AC 2 ms 1908 KB
9.txt AC 2 ms 1980 KB
sample1.txt AC 1 ms 2044 KB
sample2.txt AC 2 ms 2004 KB
sample3.txt AC 1 ms 1980 KB
sample4.txt AC 2 ms 2112 KB