Skip to content

Commit b9ae6f3

Browse files
committed
Add a test for ABC084-D
1 parent 208e5ea commit b9ae6f3

File tree

8 files changed

+81
-0
lines changed

8 files changed

+81
-0
lines changed

examples/abc084-d.rs

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

examples/tests.ron

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
name: "ABC045: C - One-stroke Path",
3636
matching: ExactWords,
3737
),
38+
"abc084-d": (
39+
name: "ABC084: D - 2017-like Number",
40+
matching: ExactWords,
41+
),
3842
"abc120-d": (
3943
name: "ABC120: D - Decayed Bridges",
4044
matching: ExactWords,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
3 7
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
13 13
3+
7 11
4+
7 11
5+
2017 2017
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
6
2+
1 53
3+
13 91
4+
37 55
5+
19 51
6+
73 91
7+
13 49
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1
2+
0
3+
0
4+
1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
4
2+
4
3+
1
4+
1
5+
1
6+
2

0 commit comments

Comments
 (0)