結果

問題 No.2758 RDQ
ユーザー titiatitia
提出日時 2024-05-17 21:46:22
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,224 bytes
コンパイル時間 12,521 ms
コンパイル使用メモリ 406,860 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2024-05-17 21:46:39
合計ジャッジ時間 16,876 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
9,884 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,948 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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