ログインしてください。
提出 #39970517
ソースコード 拡げる
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 ps = prime_factorization(p);
let ans = ps
.into_iter()
.filter(|(_, q)| q >= &n)
.map(|(p, q)| p.pow((q / n) as u32))
.product::<usize>();
println!("{}", ans);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Product and GCD |
| ユーザ | bouzuya |
| 言語 | Rust (1.42.0) |
| 得点 | 300 |
| コード長 | 742 Byte |
| 結果 | AC |
| 実行時間 | 11 ms |
| メモリ | 2160 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 1.txt | AC | 11 ms | 2128 KiB |
| 10.txt | AC | 1 ms | 2068 KiB |
| 11.txt | AC | 2 ms | 1948 KiB |
| 12.txt | AC | 1 ms | 2128 KiB |
| 13.txt | AC | 2 ms | 1976 KiB |
| 14.txt | AC | 1 ms | 2124 KiB |
| 15.txt | AC | 1 ms | 2040 KiB |
| 16.txt | AC | 3 ms | 2088 KiB |
| 17.txt | AC | 4 ms | 2104 KiB |
| 18.txt | AC | 2 ms | 2036 KiB |
| 19.txt | AC | 2 ms | 2036 KiB |
| 2.txt | AC | 2 ms | 2124 KiB |
| 20.txt | AC | 1 ms | 2104 KiB |
| 21.txt | AC | 3 ms | 2000 KiB |
| 22.txt | AC | 2 ms | 2056 KiB |
| 23.txt | AC | 8 ms | 2040 KiB |
| 24.txt | AC | 2 ms | 2160 KiB |
| 25.txt | AC | 1 ms | 1952 KiB |
| 26.txt | AC | 2 ms | 1948 KiB |
| 3.txt | AC | 1 ms | 2112 KiB |
| 4.txt | AC | 2 ms | 2056 KiB |
| 5.txt | AC | 2 ms | 2028 KiB |
| 6.txt | AC | 2 ms | 2012 KiB |
| 7.txt | AC | 2 ms | 2104 KiB |
| 8.txt | AC | 4 ms | 2084 KiB |
| 9.txt | AC | 2 ms | 2048 KiB |
| sample1.txt | AC | 2 ms | 2044 KiB |
| sample2.txt | AC | 1 ms | 2104 KiB |
| sample3.txt | AC | 2 ms | 2060 KiB |
| sample4.txt | AC | 2 ms | 2112 KiB |