Problem:
﻿Score: 100 points

Problem Statement

There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)

What is the area of this yard excluding the roads? Find it.

Note

It can be proved that the positions of the roads do not affect the area.

Constraints

A is an integer between 2 and 100 (inclusive).

B is an integer between 2 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

A B

Output

Print the area of this yard excluding the roads (in square yards).

Sample Input 1

2 2

Sample Output 1

1

In this case, the area is 1 square yard.

Sample Input 2

5 7

Sample Output 2

24

In this case, the area is 24 square yards.

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

#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::cell::{Cell, RefCell};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, thread, u16, u32, u64, u8};

fn main() {
    scan_all(io::stdin(), 1024);
    let (a, b) = (r::<u32>(), r::<u32>());
    println!("{}", (a - 1) * (b - 1));
}

thread_local! {
    static SCANNED: RefCell<Scanned> = RefCell::default();
}

fn scan_all<R: Read>(mut input: R, estimated: usize) {
    let mut buf = Vec::with_capacity(estimated);
    let _ = io::copy(&mut input, &mut buf).unwrap();
    if buf.last() != Some(&b'\n') {
        buf.push(b'\n');
    }
    SCANNED.with(|scanned| scanned.borrow_mut().buf = buf);
}

fn r<T: FromStr>() -> T
where
    T::Err: fmt::Debug,
{
    SCANNED.with(|scanned| scanned.borrow_mut().next())
}

#[allow(dead_code)]
fn rv<T: FromStr>(n: usize) -> Vec<T>
where
    T::Err: fmt::Debug,
{
    SCANNED.with(|scanned| {
        let mut scanned = scanned.borrow_mut();
        (0..n).map(|_| scanned.next()).collect()
    })
}

#[allow(dead_code)]
fn rp<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)>
where
    T1::Err: fmt::Debug,
    T2::Err: fmt::Debug,
{
    SCANNED.with(|scanned| {
        let mut scanned = scanned.borrow_mut();
        (0..n).map(|_| (scanned.next(), scanned.next())).collect()
    })
}

#[allow(dead_code)]
fn rt<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)>
where
    T1::Err: fmt::Debug,
    T2::Err: fmt::Debug,
    T3::Err: fmt::Debug,
{
    SCANNED.with(|scanned| {
        let mut scanned = scanned.borrow_mut();
        (0..n)
            .map(|_| (scanned.next(), scanned.next(), scanned.next()))
            .collect()
    })
}

#[allow(dead_code)]
fn rq<T1: FromStr, T2: FromStr, T3: FromStr, T4: FromStr>(n: usize) -> Vec<(T1, T2, T3, T4)>
where
    T1::Err: fmt::Debug,
    T2::Err: fmt::Debug,
    T3::Err: fmt::Debug,
    T4::Err: fmt::Debug,
{
    SCANNED.with(|scanned| {
        let mut scanned = scanned.borrow_mut();
        (0..n)
            .map(|_| {
                (
                    scanned.next(),
                    scanned.next(),
                    scanned.next(),
                    scanned.next(),
                )
            }).collect()
    })
}

#[allow(dead_code)]
fn rm<T: FromStr>(m: usize, n: usize) -> Vec<Vec<T>>
where
    T::Err: fmt::Debug,
{
    SCANNED.with(|scanned| {
        let mut scanned = scanned.borrow_mut();
        (0..m)
            .map(|_| (0..n).map(|_| scanned.next()).collect())
            .collect()
    })
}

#[allow(dead_code)]
fn r_char_mat<T, F: FnMut(u8) -> T>(h: usize, mut f: F) -> Vec<Vec<T>> {
    SCANNED.with(|scanned| {
        let mut scanned = scanned.borrow_mut();
        (0..h)
            .map(|_| {
                let l = scanned.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            }).collect()
    })
}

#[derive(Default)]
struct Scanned {
    buf: Vec<u8>,
    pos: usize,
}

impl Scanned {
    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }
}