Skip to content

Commit 168e020

Browse files
committed
Add an example for ABC169-C
1 parent 57c5ade commit 168e020

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

examples/abc169-c.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// https://atcoder.jp/contests/abc169/tasks/abc169_c
2+
//
3+
// 以下のクレートを使用。
4+
// - `num`
5+
// - `num-rational`
6+
// - `proconio`
7+
8+
use num::rational::Ratio;
9+
use proconio::input;
10+
11+
// 有理数型である[`num_rational::Ratio<_>`]を使う。
12+
//
13+
// `Ratio<T>`に対する`FromStr`は`"Tの形式"`または`"Tの形式/Tの形式"`を受け付ける。
14+
// よって入力をパースするときはAはそのまま、
15+
// Bは小数点下が2桁で固定なので`(_.replace('.', "") + "/100").parse().unwrap()`とすれば良い。
16+
//
17+
// そして[`.to_integer()`]で「0方向に丸めた整数」が得られるので`(_ * _).to_integer()`を答えとすれば良い。
18+
//
19+
// [`num_rational::Ratio<_>`]: https://docs.rs/num-rational/0.2.4/num_rational/struct.Ratio.html
20+
// [`.to_integer()`]: https://docs.rs/num-rational/0.2.4/num_rational/struct.Ratio.html#method.to_integer
21+
22+
fn main() {
23+
// [`proconio::input!`]で入力を読む。
24+
//
25+
// [`proconio::input!`]: https://docs.rs/proconio/0.3.6/proconio/macro.input.html
26+
input! {
27+
a: Ratio<u64>,
28+
b: String,
29+
}
30+
31+
let b = (b.replace('.', "") + "/100").parse::<Ratio<_>>().unwrap();
32+
println!("{}", (a * b).to_integer());
33+
}

test-examples.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ url = "https://atcoder.jp/contests/abc168/tasks/abc168_e"
275275
matching = "Words"
276276
meta = { using = ["maplit", "num", "proconio"] }
277277

278+
[examples.abc169-c]
279+
type = "Normal"
280+
name = "ABC169 - C - Multiplication 3"
281+
url = "https://atcoder.jp/contests/abc169/tasks/abc169_c"
282+
matching = "Words"
283+
meta = { using = ["num", "proconio"] }
284+
278285
[examples.agc020-c]
279286
type = "Normal"
280287
name = "AGC020: C - Median Sum"

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