Problem:
Score : 100 points

Problem Statement

Given is an integer N.

Takahashi chooses an integer a from the positive integers not greater than N with equal probability.

Find the probability that a is odd.

Constraints

1 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

Print the probability that a is odd.
Your output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-6}.

Sample Input 1

4

Sample Output 1

0.5000000000

There are four positive integers not greater than 4: 1, 2, 3, and 4. Among them, we have two odd numbers: 1 and 3. Thus, the answer is \frac{2}{4} = 0.5.

Sample Input 2

5

Sample Output 2

0.6000000000

Sample Input 3

1

Sample Output 3

1.0000000000

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::stdin;
use std::iter::Iterator;
use std::collections::VecDeque;

fn solve(cin: &mut ConsoleInputWrapper) {
    let n: f64 = cin.input().parse().unwrap();
    println!("{}", (n / 2f64).ceil() / n);
}

fn main() {
    let mut cin = ConsoleInputWrapper::new();
    solve(&mut cin);
}

fn min(a: i32, b: i32) -> i32 {
    if a < b { a } else { b }
}

fn max(a: i32, b: i32) -> i32 {
    if a > b { a } else { b }
}

fn split(h: i32, w: i32) -> i32 {
    let mut vec = Vec::new();
    if h > 1 {
        vec.push((h - h / 2) * w);
    }
    if w > 1 {
        vec.push((w - w / 2) * h);
    }
    match vec.iter().min() {
        Some(m) => m.clone(),
        None => i32::max_value()
    }
}

fn split2(h: i32, w: i32) -> i32 {
    let mut vec = Vec::new();
    if h > 1 {
        vec.push((h / 2) * w);
    }
    if w > 1 {
        vec.push((w / 2) * h);
    }
    match vec.iter().max() {
        Some(m) => m.clone(),
        None => i32::min_value()
    }
}

struct ConsoleInputWrapper {
    queue: VecDeque<String>
}

impl ConsoleInputWrapper {
    fn new() -> ConsoleInputWrapper {
        ConsoleInputWrapper {
            queue: VecDeque::new()
        }
    }
    fn input(&mut self) -> String {
        if self.queue.len() <= 0 {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let list: Vec<&str> = s.split_whitespace().collect();
            for string in list {
                self.queue.push_back(String::from(string));
            }
        }
        self.queue.pop_front().unwrap()
    }
}