結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー |
|
提出日時 | 2021-01-22 22:35:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 633 ms / 2,000 ms |
コード長 | 911 bytes |
コンパイル時間 | 3,078 ms |
コンパイル使用メモリ | 201,516 KB |
最終ジャッジ日時 | 2025-01-18 04:50:49 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#define _USE_MATH_DEFINES#include <bits/stdc++.h>using namespace std;signed main() {ios::sync_with_stdio(false); cin.tie(0);int n, k, m;cin >> n >> k >> m;vector<vector<int>> a(4, vector<int>(n));for (int i = 0; i < 4; i++) {for (auto& x : a[i]) cin >> x;sort(a[i].begin(), a[i].end());}vector<int> vals(n);for (int j = 0; j < n; j++) {vector<int> v;for (int i = 0; i < 4; i++) v.emplace_back(a[i][j]);vals[j] = *max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end());}long long ans = 0;auto calc = [&] (int x) -> long long {long long res = 1;long long c = x;int kk = k;while (kk > 0) {if (kk & 1) {res *= c;res %= m;}c *= c;c %= m;kk >>= 1;}return res % m;};for (auto x : vals) {(ans += calc(x)) %= m;}cout << ans << endl;return 0;}