Skip to content

Commit f25e972

Browse files
committed
Add an example for ABC165-B
1 parent f1631ca commit f25e972

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

examples/abc165-b.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://atcoder.jp/contests/abc165/tasks/abc165_b
2+
//
3+
// 以下のクレートを使用。
4+
// - `itertools`
5+
// - `proconio`
6+
7+
use proconio::input;
8+
9+
fn main() {
10+
// `proconio::input!`。
11+
//
12+
// https://docs.rs/proconio/0.3.6/proconio/macro.input.html
13+
input! {
14+
x: u64,
15+
}
16+
17+
// `itertools::iterate`は`std::iter::successors`の`Some`固定版。
18+
// 「X円一歩手前」で打ち切ったものを`count`するとちょうど答えになる。
19+
//
20+
// https://docs.rs/itertools/0.9.0/itertools/fn.iterate.html
21+
let ans = itertools::iterate(100, |m| m + m / 100)
22+
.take_while(|&m| m < x)
23+
.count();
24+
25+
println!("{}", ans);
26+
}

test-examples.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ url = "https://atcoder.jp/contests/abc162/tasks/abc162_c"
233233
matching = "Words"
234234
meta = { using = ["itertools", "num", "proconio"] }
235235

236+
[examples.abc165-b]
237+
type = "Normal"
238+
name = "ABC165 - B - 1%"
239+
url = "https://atcoder.jp/contests/abc165/tasks/abc165_b"
240+
matching = "Words"
241+
meta = { using = ["itertools", "proconio"] }
242+
236243
[examples.agc020-c]
237244
type = "Normal"
238245
name = "AGC020: C - Median Sum"

0 commit comments

Comments
 (0)