結果

問題 No.752 mod数列
ユーザー 特命ログイン特命ログイン
提出日時 2018-11-09 22:56:24
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 949 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 142,168 KB
実行使用メモリ 811,928 KB
最終ジャッジ日時 2023-08-13 12:01:35
合計ジャッジ時間 5,155 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
8,320 KB
testcase_01 AC 8 ms
8,560 KB
testcase_02 AC 5 ms
5,220 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 8 ms
8,856 KB
testcase_06 AC 5 ms
4,736 KB
testcase_07 AC 9 ms
9,140 KB
testcase_08 AC 10 ms
9,652 KB
testcase_09 AC 7 ms
7,612 KB
testcase_10 RE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{Read,stdin};

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let p = get!();
    let mut tb = vec![0; 1 + p as usize];
    for i in 1..=p {
        let j = i as usize;
        tb[j] += tb[j - 1] + p % i;
    }
    let q = get!();
    for _ in 0..q {
        let li = get!();
        let ri = get!();
        if p < li {
            let ans = (ri - li + 1) * p;
            println!("{}", ans);
        } else if p < ri {
            let mut ans = (ri - p) * p;
            ans += tb[p as usize] - tb[li as usize - 1];
            println!("{}", ans);
        } else {
            let ans = tb[ri as usize] - tb[li as usize - 1];
            println!("{}", ans);
        }
        
    }

}
0