結果

問題 No.1185 完全な3の倍数
ユーザー soraie_soraie_
提出日時 2022-01-11 17:52:31
言語 Rust
(1.77.0)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 2,954 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 164,796 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 20:42:54
合計ジャッジ時間 4,509 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 85 ms
5,376 KB
testcase_04 AC 84 ms
5,376 KB
testcase_05 AC 86 ms
5,376 KB
testcase_06 AC 86 ms
5,376 KB
testcase_07 AC 83 ms
5,376 KB
testcase_08 AC 363 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 85 ms
5,376 KB
testcase_20 AC 85 ms
5,376 KB
testcase_21 AC 87 ms
5,376 KB
testcase_22 AC 85 ms
5,376 KB
testcase_23 AC 84 ms
5,376 KB
testcase_24 AC 85 ms
5,376 KB
testcase_25 AC 18 ms
5,376 KB
testcase_26 AC 87 ms
5,376 KB
testcase_27 AC 85 ms
5,376 KB
testcase_28 AC 87 ms
5,376 KB
testcase_29 AC 86 ms
5,376 KB
testcase_30 AC 87 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 84 ms
5,376 KB
testcase_33 AC 18 ms
5,376 KB
testcase_34 AC 85 ms
5,376 KB
testcase_35 AC 86 ms
5,376 KB
testcase_36 AC 84 ms
5,376 KB
testcase_37 AC 85 ms
5,376 KB
testcase_38 AC 87 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]

// use itertools::Itertools;
// use proconio::{fastout, input, marker::*};

// #[fastout]
fn main() {
    // input!{n:usize}
    let mut io = IO::new();
    let n = io.next_usize();
    let sz = n.to_string().len();
    let mut ans = 0;
    for b in 0..4usize.pow(sz as u32) {
        let mut cur = String::from("");
        let mut c = b;
        for _ in 0..sz {
            cur.push("0369".chars().collect::<Vec<char>>()[c % 4]);
            c /= 4;
        }
        let cn = cur.parse::<usize>().unwrap();
        if 102 <= cn && cn <= n {
            ans += 1;
        }
    }
    for i in (12..=99).step_by(3) {
        if i <= n {
            ans += 1;
        }
    }
    println!("{}",ans);
}


// copied IO from https://atcoder.jp/contests/abc234/submissions/28412243
pub struct IO {
    iter: std::str::SplitAsciiWhitespace<'static>,
    buf: std::io::BufWriter<std::io::StdoutLock<'static>>,
}

impl Default for IO {
    fn default() -> Self {
        Self::new()
    }
}

impl IO {
    pub fn new() -> Self {
        use std::io::*;
        let mut input = String::new();
        std::io::stdin().read_to_string(&mut input).unwrap();
        let input = Box::leak(input.into_boxed_str());
        let out = Box::new(stdout());
        IO {
            iter: input.split_ascii_whitespace(),
            buf: BufWriter::new(Box::leak(out).lock()),
        }
    }
    pub fn next_str(&mut self) -> &str {
        self.iter.next().unwrap()
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T
        where
            <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        self.iter.next().unwrap().parse().unwrap()
    }
    pub fn next_usize(&mut self) -> usize {
        self.read()
    }
    pub fn next_uint(&mut self) -> u64 {
        self.read()
    }
    pub fn next_int(&mut self) -> i64 {
        self.read()
    }
    pub fn next_float(&mut self) -> f64 {
        self.read()
    }
    pub fn next_chars(&mut self) -> std::str::Chars {
        self.next_str().chars()
    }
    pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T>
        where
            <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect::<Vec<_>>()
    }
    pub fn print<T: std::fmt::Display>(&mut self, t: T) {
        use std::io::Write;
        write!(self.buf, "{}", t).unwrap();
    }
    pub fn println<T: std::fmt::Display>(&mut self, t: T) {
        self.print(t);
        self.print("\n");
    }
    pub fn print_iter<T: std::fmt::Display, I: Iterator<Item=T>>(
        &mut self,
        mut iter: I,
        sep: &str,
    ) {
        if let Some(v) = iter.next() {
            self.print(v);
            for vi in iter {
                self.print(sep);
                self.print(vi);
            }
        }
        self.print("\n");
    }
    pub fn flush(&mut self) {
        use std::io::Write;
        self.buf.flush().unwrap();
    }
}
0