結果

問題 No.6 使いものにならないハッシュ
ユーザー pessimist
提出日時 2025-06-07 20:04:43
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 768 bytes
コンパイル時間 11,218 ms
コンパイル使用メモリ 390,104 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-07 20:04:57
合計ジャッジ時間 12,929 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::*;
fn main(){
    input!{k:usize,n:usize}
    let mut is_p = vec![true; n+1];
    is_p[0]=false;is_p[1]=false;
    let mut hash = vec![0; 200010];
    let mut list = vec![];
    for i in 2..=n{
        if !is_p[i]{ continue; }
        if i >= k {hash[list.len()]=(i-1)%9+1; list.push(i);}
        for j in (i*i..=n).step_by(i){
            is_p[j]=false;
        }
    }

    let mut mx = 0;
    let n = list.len();
    let mut ans = !0;
    let (mut l, mut r) = (0, 0);
    let mut cnt = [0; 10];
    while l<n{
        while r<n && cnt[hash[r]]==0{
            cnt[hash[r]]+=1;
            r+=1;
        }
        if mx<=r-l{
            mx=r-l;
            ans=list[l];
        }
        cnt[hash[l]]-=1;
        l+=1;
    }
    println!("{}", ans);
}
0