Skip to content

Commit 69a4c44

Browse files
committed
Add an example for ABC168-C
1 parent 16a9595 commit 69a4c44

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

examples/abc168-c.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// https://atcoder.jp/contests/abc168/tasks/abc168_c
2+
//
3+
// 以下のクレートを使用。
4+
// - `num`
5+
// - `num-complex`
6+
// - `proconio`
7+
8+
use num::Complex;
9+
use proconio::input;
10+
use std::f64::consts::PI;
11+
12+
fn main() {
13+
// `proconio::input!`。
14+
//
15+
// https://docs.rs/proconio/0.3.6/proconio/macro.input.html
16+
input! {
17+
a: f64,
18+
b: f64,
19+
h: f64,
20+
m: f64,
21+
}
22+
23+
// 座標として`num_complex::Complex<f64>`を使う。
24+
// `Complex::from_polar`でxとθから(x・cosθ, x・sinθ)を得ることができ、また`Complex::norm`で2点間の距離を出すことができる。
25+
//
26+
// https://docs.rs/num-complex/0.2.4/num_complex/struct.Complex.html
27+
// https://docs.rs/num-complex/0.2.4/num_complex/struct.Complex.html#method.from_polar
28+
// https://docs.rs/num-complex/0.2.4/num_complex/struct.Complex.html#method.norm
29+
30+
let p1 = Complex::from_polar(&a, &(h * PI / 6.0 + m * PI / 360.0));
31+
let p2 = Complex::from_polar(&b, &(m * PI / 30.0));
32+
let ans = (p1 - p2).norm();
33+
println!("{}", ans);
34+
}

test-examples.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ url = "https://atcoder.jp/contests/abc168/tasks/abc168_b"
261261
matching = "Words"
262262
meta = { using = ["ascii", "proconio"] }
263263

264+
[examples.abc168-c]
265+
type = "Normal"
266+
name = "ABC168 - C - : (Colon)"
267+
url = "https://atcoder.jp/contests/abc168/tasks/abc168_c"
268+
matching = { FloatOr = { abs = 1e-9, rel = 1e-9 } }
269+
meta = { using = ["num", "proconio"] }
270+
264271
[examples.agc020-c]
265272
type = "Normal"
266273
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