結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー |
|
提出日時 | 2021-01-22 22:11:30 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 349 ms / 2,000 ms |
コード長 | 1,282 bytes |
コンパイル時間 | 13,978 ms |
コンパイル使用メモリ | 403,728 KB |
実行使用メモリ | 16,796 KB |
最終ジャッジ日時 | 2024-12-28 01:27:23 |
合計ジャッジ時間 | 30,095 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
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);}