結果
問題 | No.896 友達以上恋人未満 |
ユーザー |
|
提出日時 | 2019-09-27 23:06:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,290 ms / 3,500 ms |
コード長 | 1,692 bytes |
コンパイル時間 | 870 ms |
コンパイル使用メモリ | 99,500 KB |
実行使用メモリ | 150,812 KB |
最終ジャッジ日時 | 2024-11-14 21:41:51 |
合計ジャッジ時間 | 4,481 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; } vector<char> V(X+1); for (int i = 2; i <= X; ++i) { if(!V[i]){ for (int j = X/i; j != 0; --j) { V[i*j] = 1; A[j] += A[i*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; }