Problem:
Score: 300 points

Problem Statement

AtCoder Mart sells 1000000 of each of the six items below:

Riceballs, priced at 100 yen (the currency of Japan) each

Sandwiches, priced at 101 yen each

Cookies, priced at 102 yen each

Cakes, priced at 103 yen each

Candies, priced at 104 yen each

Computers, priced at 105 yen each

Takahashi wants to buy some of them that cost exactly X yen in total.
Determine whether this is possible.

(Ignore consumption tax.)

Constraints

1 \leq X \leq 100000

X is an integer.

Input

Input is given from Standard Input in the following format:

X

Output

If it is possible to buy some set of items that cost exactly X yen in total, print 1; otherwise, print 0.

Sample Input 1

615

Sample Output 1

1

For example, we can buy one of each kind of item, which will cost 100+101+102+103+104+105=615 yen in total.

Sample Input 2

217

Sample Output 2

0

No set of items costs 217 yen in total.

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

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let x = scan.read::<i64>();
    let n = 1000000i64;
    let mut is_ok = false;
    'outer: for a in 0..n {
        let mut rest = x - a*100;
        if rest == 0 {is_ok=true;break 'outer;}
        if rest < 0 {break;}
        for b in 0..n {
            rest = x - a*100 - b*101;
            if rest == 0 {is_ok=true;break 'outer;}
            if rest < 0 {break;}
            for c in 0..n {
                rest = x - a*100 - b*101 - c*102;
                if rest == 0 {is_ok=true;break 'outer;}
                if rest < 0 {break;}
                for d in 0..n {
                    rest = x - a*100 - b*101 - c*102 - d*103;
                    if rest == 0 {is_ok=true;break 'outer;}
                    if rest < 0 {break;}
                    for e in 0..n {
                        rest = x - a*100 - b*101 - c*102 - d*103 - e*104;
                        if rest == 0 {is_ok=true;break 'outer;}
                        if rest < 0 {break;}
                        for f in 0..n {
                            rest = x - a*100 - b*101 - c*102 - d*103 - e*104 - f*105;
                            if rest == 0 {is_ok=true;break 'outer;}
                            if rest < 0 {break;}
                        }
                    }
                }
            }
        }
    }
    println!("{}", if is_ok {1} else {0});
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion