結果
| 問題 |
No.896 友達以上恋人未満
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-27 23:16:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,559 ms / 3,500 ms |
| コード長 | 1,795 bytes |
| コンパイル時間 | 1,550 ms |
| コンパイル使用メモリ | 169,852 KB |
| 実行使用メモリ | 81,616 KB |
| 最終ジャッジ日時 | 2024-09-25 01:45:52 |
| 合計ジャッジ時間 | 6,363 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MAX_MOD = 1 << 24;
constexpr int MAXM = 1000;
ll z[MAX_MOD];
int a[MAXM], b[MAXM], x[MAXM], y[MAXM];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int m, n;
int mulx, addx, muly, addy;
int mod;
cin >> m >> n >> mulx >> addx >> muly >> addy >> mod;
for (int i = 0; i < m; i++) {
cin >> x[i];
}
for (int i = 0; i < m; i++) {
cin >> y[i];
}
for (int i = 0; i < m; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
cin >> b[i];
}
for (int i = 0; i < m; i++) {
z[x[i]] += y[i];
}
ll curx = x[m - 1], cury = y[m - 1], cura = a[m-1], curb = b[m-1];
for (int i = m; i < n; i++) {
curx = ((curx * mulx + addx) & (mod - 1));
cury = ((cury * muly + addy) & (mod - 1));
z[curx] += cury;
}
for (int aa = 1; aa <= mod; aa++) {
for (int i = aa * 2; i < mod; i += aa) {
z[aa] += z[i];
}
}
ll all_ans = 0;
for (int i = 0; i < m; i++) {
ll ans = 0;
if ((ll)a[i] * b[i] >= mod) {
ans = (a[i] >= mod ? 0 : z[a[i]]);
} else {
ans = (a[i] >= mod ? 0 : z[a[i]] - z[a[i] * b[i]]);
}
cout << ans << "\n";
all_ans ^= ans;
}
for (int i = m; i < n; i++) {
cura = ((cura * mulx + addx + mod - 1) & (mod - 1)) + 1;
curb = ((curb * muly + addy + mod - 1) & (mod - 1)) + 1;
ll ans = 0;
if (cura * curb >= mod) {
ans = (cura >= mod ? 0 : z[cura]);
} else {
ans = (cura >= mod ? 0 : z[cura] - z[cura * curb]);
}
all_ans ^= ans;
}
cout << all_ans << "\n";
return 0;
}