File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -275,6 +275,13 @@ url = "https://atcoder.jp/contests/abc168/tasks/abc168_e"
275
275
matching = " Words"
276
276
meta = { using = [" maplit" , " num" , " proconio" ] }
277
277
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
+
278
285
[examples .agc020-c ]
279
286
type = " Normal"
280
287
name = " AGC020: C - Median Sum"
You can’t perform that action at this time.
0 commit comments