結果

問題 No.752 mod数列
ユーザー 特命ログイン特命ログイン
提出日時 2018-11-09 22:49:34
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 876 bytes
コンパイル時間 13,266 ms
コンパイル使用メモリ 378,388 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-01 05:17:40
合計ジャッジ時間 15,763 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 3 ms
5,248 KB
testcase_02 AC 3 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
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 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;
            for i in li..=p {
                ans += p % i;
            }
            println!("{}", ans);
        } else {
            let mut ans = 0;
            for i in li..=ri {
                ans += p % i;
            }
            println!("{}", ans);
        }
        
    }

}
0