結果

問題 No.3455 N-beatsu
コンテスト
ユーザー NakLon131
提出日時 2026-02-28 14:28:29
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,013 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,629 ms
コンパイル使用メモリ 202,400 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-28 14:28:36
合計ジャッジ時間 2,956 ms
ジャッジサーバーID
(参考情報)
judge7 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use proconio::input;

fn main() {
    input! {
        n: usize, // ナベアツ数
        q: usize, // クエリ数
        x: [usize; q],
    }

    for xx in x {
        let ans = solve(n, xx);
        println!("{}", if ans {"Yes"} else {"No"});
    }
}

fn solve(n: usize, x: usize) -> bool {
    // xがNの倍数か
    if is_divide(x, n) {
        return true;
    }

    // xの連続部分文字列がNと一致するかを判定
    is_match(x, n)
}

fn is_divide(x: usize, n: usize) -> bool {
    x % n == 0
}

fn is_match(x: usize, n: usize) -> bool {
    let n_chars : Vec<char> = n.to_string().chars().collect();
    let n_len = n_chars.len();
    
    let x_chars : Vec<char> = x.to_string().chars().collect();
    let x_len = x_chars.len();

    if n_len > x_len {
        return false;
    }

    for i in 0..x_len-n_len+1 {
        if &x_chars[i..i+n_len] == &n_chars[0..n_len] {
            return true;
        }
    }
    false
}

/*
n = 10 -> 2桁
x = 100 -> 3桁

[10] [10]
[01] [10]


*/
0