結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tonyu0tonyu0
提出日時 2021-01-22 22:11:30
言語 Rust
(1.77.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 1,282 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 145,436 KB
実行使用メモリ 17,076 KB
最終ジャッジ日時 2023-08-27 19:31:11
合計ジャッジ時間 17,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 101 ms
9,688 KB
testcase_04 AC 100 ms
9,668 KB
testcase_05 AC 90 ms
9,408 KB
testcase_06 AC 90 ms
9,372 KB
testcase_07 AC 135 ms
15,120 KB
testcase_08 AC 135 ms
15,044 KB
testcase_09 AC 39 ms
5,496 KB
testcase_10 AC 39 ms
5,496 KB
testcase_11 AC 175 ms
16,380 KB
testcase_12 AC 176 ms
16,428 KB
testcase_13 AC 113 ms
14,040 KB
testcase_14 AC 112 ms
14,060 KB
testcase_15 AC 101 ms
9,428 KB
testcase_16 AC 99 ms
9,408 KB
testcase_17 AC 191 ms
16,596 KB
testcase_18 AC 191 ms
16,700 KB
testcase_19 AC 163 ms
15,928 KB
testcase_20 AC 164 ms
15,880 KB
testcase_21 AC 179 ms
16,324 KB
testcase_22 AC 178 ms
16,300 KB
testcase_23 AC 117 ms
14,456 KB
testcase_24 AC 117 ms
14,404 KB
testcase_25 AC 19 ms
4,376 KB
testcase_26 AC 19 ms
4,380 KB
testcase_27 AC 63 ms
8,104 KB
testcase_28 AC 62 ms
8,164 KB
testcase_29 AC 76 ms
8,896 KB
testcase_30 AC 76 ms
8,884 KB
testcase_31 AC 102 ms
9,632 KB
testcase_32 AC 101 ms
9,684 KB
testcase_33 AC 75 ms
8,620 KB
testcase_34 AC 74 ms
8,624 KB
testcase_35 AC 99 ms
9,692 KB
testcase_36 AC 97 ms
9,668 KB
testcase_37 AC 19 ms
4,380 KB
testcase_38 AC 19 ms
4,380 KB
testcase_39 AC 17 ms
4,376 KB
testcase_40 AC 17 ms
4,376 KB
testcase_41 AC 35 ms
5,232 KB
testcase_42 AC 34 ms
5,248 KB
testcase_43 AC 27 ms
4,956 KB
testcase_44 AC 183 ms
16,788 KB
testcase_45 AC 79 ms
8,836 KB
testcase_46 AC 27 ms
4,984 KB
testcase_47 AC 136 ms
14,680 KB
testcase_48 AC 123 ms
14,628 KB
testcase_49 AC 124 ms
14,720 KB
testcase_50 AC 95 ms
9,428 KB
testcase_51 AC 5 ms
4,380 KB
testcase_52 AC 165 ms
16,144 KB
testcase_53 AC 185 ms
17,008 KB
testcase_54 AC 197 ms
17,048 KB
testcase_55 AC 195 ms
17,064 KB
testcase_56 AC 196 ms
17,072 KB
testcase_57 AC 200 ms
17,064 KB
testcase_58 AC 196 ms
17,052 KB
testcase_59 AC 194 ms
17,076 KB
testcase_60 AC 189 ms
17,016 KB
testcase_61 AC 179 ms
17,076 KB
testcase_62 AC 194 ms
17,056 KB
testcase_63 AC 194 ms
17,056 KB
testcase_64 AC 198 ms
17,048 KB
testcase_65 AC 195 ms
17,012 KB
testcase_66 AC 192 ms
17,060 KB
testcase_67 AC 203 ms
17,064 KB
testcase_68 AC 190 ms
17,016 KB
testcase_69 AC 176 ms
17,072 KB
testcase_70 AC 177 ms
17,048 KB
testcase_71 AC 173 ms
17,056 KB
testcase_72 AC 200 ms
17,072 KB
testcase_73 AC 168 ms
17,052 KB
testcase_74 AC 165 ms
17,060 KB
testcase_75 AC 167 ms
17,056 KB
testcase_76 AC 166 ms
17,020 KB
testcase_77 AC 168 ms
17,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::*;
use std::io::*;
fn mod_pow(mut x: usize, mut e: usize, m: usize) -> usize {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % m;
        }
        x = x * x % m;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();
    let mut p: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut e: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut h: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    p.sort();
    e.sort();
    a.sort();
    h.sort();
    let mut ans = 0;
    for i in 0..n {
        let d = max(p[i], max(e[i], max(a[i], h[i]))) - min(p[i], min(e[i], min(a[i], h[i])));
        ans = (ans + mod_pow(d, k, m)) % m;
    }
    println!("{}", ans);
}
0