Skip to content

Commit 26162da

Browse files
committed
Add a test for ABC084-D
1 parent 88391c6 commit 26162da

File tree

8 files changed

+79
-0
lines changed

8 files changed

+79
-0
lines changed

examples/abc084-d.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
let hi = lrs.iter().map(|&(_, r)| r).max().unwrap();
42+
let sieve = Sieve::new(hi);
43+
let nums = (0..=hi)
44+
.map(|k| u32::from(sieve.is_prime(k) && sieve.is_prime((k + 1) / 2)))
45+
.cumsum()
46+
.collect::<Vec<u32>>();
47+
for (l, r) in lrs {
48+
println!("{}", nums[r] - nums[l - 1]);
49+
}
50+
}

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy