Problem:
Score: 100 points

Problem Statement

In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.

Integers M_1, D_1, M_2, and D_2 will be given as input.

It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.

Determine whether the date 2019-M_1-D_1 is the last day of a month.

Constraints

Both 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar.

The date 2019-M_2-D_2 follows 2019-M_1-D_1.

Input

Input is given from Standard Input in the following format:

M_1 D_1
M_2 D_2

Output

If the date 2019-M_1-D_1 is the last day of a month, print 1; otherwise, print 0.

Sample Input 1

11 16
11 17

Sample Output 1

0

November 16 is not the last day of a month.

Sample Input 2

11 30
12 1

Sample Output 2

1

November 30 is the last day of November.

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let x: usize = read().unwrap();
    let v: Vec<usize> = vec![105, 104, 103, 102, 101, 100];
    if x < 100 {
        println!("{}", 0);
    } else {
        let mut res = 0;
        let mut nums: Vec<usize> = vec![0, 0, 0, 0, 0, 0];
        nums[0] = x / v[0];
        for a in 0..nums[0] + 1 {
            nums[1] = (x - v[0] * a) / v[1];
            for b in 0..nums[1] + 1 {
                nums[2] = (x - v[0] * a - v[1] * b) / v[2];
                for c in 0..nums[2] + 1 {
                    nums[3] = ((x - v[0] * a - v[1] * b - v[2] * c) / v[3]);
                    for d in 0..nums[3] + 1 {
                        nums[4] = ((x - v[0] * a - v[1] * b - v[2] * c - v[3] * d) / v[4]);
                        for e in 0..nums[4] + 1 {
                            let price = x - a * v[0] + b * v[1] + c * v[2] + d * v[3] + e * v[4];
                            nums[5] = price / v[5];
                            if price % v[5] == 0 {
                                // println!("{:?}", nums);
                                res = 1;
                                break;
                            }
                        }
                    }
                }
            }
        }
        println!("{}", res);
    }
}