結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー Kyo_s_sKyo_s_s
提出日時 2023-11-27 16:11:52
言語 Rust
(1.77.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,551 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 185,692 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-27 16:11:55
合計ジャッジ時間 2,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 24 ms
6,676 KB
testcase_05 AC 24 ms
6,676 KB
testcase_06 AC 22 ms
6,676 KB
testcase_07 AC 24 ms
6,676 KB
testcase_08 AC 24 ms
6,676 KB
testcase_09 AC 23 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
    input! {
        t: usize,
        query: [[usize; 10]; t],
    }

    for query in query {
        let m = query[0] as i64;
        let base = {
            let mut base: i64 = 0;
            for i in 1..10 {
                for _ in 0..query[i] {
                    base = base * 10 + i as i64;
                }
            }
            base * 1000000000
        };
        let mo = base % m;
        let ans = base + (m - mo) % m;
        println!("{}\n", ans);
        if ans % m != 0 || ans > 1000000000000000000 {
            panic!("{} {}", ans, m);
        }
    }
}
0