結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー |
|
提出日時 | 2021-01-22 23:10:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 457 ms / 2,000 ms |
コード長 | 953 bytes |
コンパイル時間 | 2,765 ms |
コンパイル使用メモリ | 197,416 KB |
最終ジャッジ日時 | 2025-01-18 05:47:31 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
/** * author: shu8Cream * created: 22.01.2021 22:56:51 **/ #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<int,int>; using vi = vector<int>; using vvi = vector<vi>; ll mod_pow(ll a, ll b, ll n){ if(b==0) return 1; if(b%2!=0) return a * mod_pow(a, b-1, n) % n; else return mod_pow(a * a % n, b / 2, n) % n; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll n,k,m; cin >> n >> k >> m; vi p(n),e(n),a(n),h(n); rep(i,n) cin >> p[i]; rep(i,n) cin >> e[i]; rep(i,n) cin >> a[i]; rep(i,n) cin >> h[i]; sort(all(p)); sort(all(e)); sort(all(a)); sort(all(h)); ll ans = 0; rep(i,n){ ll x = max({p[i], e[i], a[i], h[i]}); ll y = min({p[i], e[i], a[i], h[i]}); ans+=mod_pow(x-y,k,m); } ans%=m; cout << ans << endl; }