Submission #6794378
Source Code Expand
use std::fs::File; use std::io::{stdout, BufWriter, Read, Write}; use std::thread; fn main() { thread::Builder::new() .stack_size(32 * 1024 * 1024) // 32MB .spawn(run) .unwrap() .join() .unwrap(); } /// ローカル環境なら _in.txt から入力を受ける fn read_input() -> String { let stdin = std::io::stdin(); let mut s = String::new(); match option_env!("LOCAL") { Some(_) => File::open("src/_in.txt") .expect("File not found") .read_to_string(&mut s) .unwrap(), None => stdin.lock().read_to_string(&mut s).unwrap(), }; s } fn run() { let out = stdout(); let mut out = BufWriter::new(out.lock()); let input = read_input(); let mut input = input.split_whitespace(); let r: f64 = input.next().unwrap().parse().unwrap(); let n: i64 = input.next().unwrap().parse().unwrap(); let m: i64 = input.next().unwrap().parse().unwrap(); let lengths: Vec<f64> = (0..n + 1) .map(|i| { let sin = 2.0 * r * i as f64 / n as f64 - r; let cos = (f64::powf(r, 2.0) - f64::powf(sin, 2.0)).sqrt(); cos * 2.0 }) .collect(); let ans: f64 = (1..n + m) .map(|i| { let mut ret: f64 = 0.0; if 0 <= i && i < n { ret = ret.max(lengths[i as usize]); } if 0 <= i - m && i - m < n { ret = ret.max(lengths[(i - m) as usize]) } ret }) .sum(); writeln!(out, "{}", ans).ok(); }
Submission Info
Submission Time | |
---|---|
Task | B - ステップカット |
User | nohtaray |
Language | Rust (1.15.1) |
Score | 200 |
Code Size | 1657 Byte |
Status | AC |
Exec Time | 5 ms |
Memory | 8572 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_hand_01.txt, 20_hand_02.txt, 20_hand_03.txt, 20_hand_04.txt, 20_hand_05.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 3 ms | 8572 KB |
00_example_02.txt | AC | 3 ms | 8572 KB |
00_example_03.txt | AC | 4 ms | 8572 KB |
10_rand_01.txt | AC | 3 ms | 8572 KB |
10_rand_02.txt | AC | 3 ms | 8572 KB |
10_rand_03.txt | AC | 4 ms | 8572 KB |
10_rand_04.txt | AC | 3 ms | 8572 KB |
10_rand_05.txt | AC | 3 ms | 8572 KB |
10_rand_06.txt | AC | 3 ms | 8572 KB |
10_rand_07.txt | AC | 3 ms | 8572 KB |
10_rand_08.txt | AC | 3 ms | 8572 KB |
20_hand_01.txt | AC | 5 ms | 8572 KB |
20_hand_02.txt | AC | 5 ms | 8572 KB |
20_hand_03.txt | AC | 5 ms | 8572 KB |
20_hand_04.txt | AC | 3 ms | 8572 KB |
20_hand_05.txt | AC | 3 ms | 8572 KB |