結果
| 問題 |
No.896 友達以上恋人未満
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-27 23:02:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,533 ms / 3,500 ms |
| コード長 | 1,605 bytes |
| コンパイル時間 | 980 ms |
| コンパイル使用メモリ | 99,412 KB |
| 実行使用メモリ | 134,416 KB |
| 最終ジャッジ日時 | 2024-11-14 21:42:08 |
| 合計ジャッジ時間 | 7,358 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
int main() {
ll m, n, mulx, addx, muly, addy, X;
cin >> m >> n >> mulx >> addx >> muly >> addy >> X;
vector<ll> x(m), y(m), a(m), b(m);
for (auto &&i : x) scanf("%lld", &i);
for (auto &&i : y) scanf("%lld", &i);
for (auto &&i : a) scanf("%lld", &i);
for (auto &&i : b) scanf("%lld", &i);
vector<ll> A(X+1);
for (int i = 0; i < m; ++i) {
A[x[i]] += y[i];
}
ll nowx = x.back(), nowy = y.back();
for (int j = m; j < n; ++j) {
nowx = (nowx * mulx + addx)&(X-1);
nowy = (nowy * muly + addy)&(X-1);
A[nowx] += nowy;
}
for (int i = 1; i <= X; ++i) {
for (int j = i*2; j <= X; j += i) {
A[i] += A[j];
}
}
ll anss = 0;
for (int i = 0; i < m; ++i) {
ll ans = A[a[i]];
if(a[i]*b[i] <= X) ans -= A[a[i]*b[i]];
printf("%lld\n",ans);
anss ^= ans;
}
ll nowa = a.back(), nowb = b.back();
for (int j = m; j < n; ++j) {
nowa = ((nowa * mulx + addx+X-1)&(X-1)) + 1;
nowb = ((nowb * muly + addy+X-1)&(X-1)) + 1;
ll ans = A[nowa];
if(nowa*nowb <= X) ans -= A[nowa*nowb];
anss ^= ans;
}
printf("%lld\n", anss);
return 0;
}