結果

問題 No.2758 RDQ
ユーザー titia
提出日時 2024-05-17 21:46:22
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 1,224 bytes
コンパイル時間 12,905 ms
コンパイル使用メモリ 395,324 KB
実行使用メモリ 16,712 KB
最終ジャッジ日時 2024-12-20 13:31:29
合計ジャッジ時間 60,499 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
  --> src/main.rs:12:9
   |
12 |     let n: usize = first_line_parts.next().unwrap().parse().unwrap();
   |         ^ help: if this is intentional, prefix it with an underscore: `_n`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

use std::io;
use std::io::prelude::*;

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let mut lines = input.lines();
    
    // Read N and Q
    let first_line = lines.next().unwrap();
    let mut first_line_parts = first_line.split_whitespace();
    let n: usize = first_line_parts.next().unwrap().parse().unwrap();
    let q: usize = first_line_parts.next().unwrap().parse().unwrap();
    
    // Read array A
    let second_line = lines.next().unwrap();
    let a: Vec<i32> = second_line.split_whitespace()
                                 .map(|s| s.parse().unwrap())
                                 .collect();
    
    // Process each query
    for _ in 0..q {
        let query_line = lines.next().unwrap();
        let mut query_parts = query_line.split_whitespace();
        let l: usize = query_parts.next().unwrap().parse().unwrap();
        let r: usize = query_parts.next().unwrap().parse().unwrap();
        let k: i32 = query_parts.next().unwrap().parse().unwrap();
        
        let mut ans = 0;
        for ind in (l-1)..r {
            if a[ind] % k == 0 {
                ans += 1;
            }
        }
        println!("{}", ans);
    }
}
0