Skip to content

Commit 84afc96

Browse files
committed
Add a test for ABC142-D
1 parent b9ae6f3 commit 84afc96

File tree

8 files changed

+63
-0
lines changed

8 files changed

+63
-0
lines changed

examples/abc142-d.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// https://atcoder.jp/contests/abc142/tasks/abc142_d
2+
3+
use primal::Sieve;
4+
5+
use std::cmp::max;
6+
use std::collections::HashSet;
7+
8+
fn main() {
9+
// use std::io::{self, Read as _};
10+
//
11+
// let mut input = "".to_owned();
12+
// io::stdin().read_to_string(&mut input).unwrap();
13+
// let mut input = input.split_whitespace();
14+
// macro_rules! read {
15+
// ([$t:tt; $n:expr]) => {
16+
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
17+
// };
18+
// (($($t:tt),+)) => {
19+
// ($(read!($t)),*)
20+
// };
21+
// (_1based) => {
22+
// read!(usize) - 1
23+
// };
24+
// (_bytes) => {
25+
// read!(String).into_bytes()
26+
// };
27+
// ($ty:ty) => {
28+
// input.next().unwrap().parse::<$ty>().unwrap()
29+
// };
30+
// }
31+
//
32+
// let (n, m) = read!((usize, usize));
33+
34+
use proconio::input;
35+
36+
input! {
37+
a: usize,
38+
b: usize,
39+
}
40+
41+
// サンプルケースでしか試してないので嘘かもしれない。
42+
43+
let sieve = Sieve::new(num_integer::sqrt(max(a, b)));
44+
let bases = |k| -> HashSet<_> {
45+
sieve
46+
.factor(k)
47+
.unwrap()
48+
.into_iter()
49+
.map(|(p, _)| p)
50+
.collect()
51+
};
52+
println!("{}", (&bases(a) & &bases(b)).len() + 1);
53+
}

examples/tests.ron

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@
4343
name: "ABC120: D - Decayed Bridges",
4444
matching: ExactWords,
4545
),
46+
"abc142-d": (
47+
name: "ABC124: D - Disjoint Set of Common Divisors",
48+
matching: ExactWords,
49+
),
4650
}
4751
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12 18
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
420 660
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2019
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

0 commit comments

Comments
 (0)