結果

問題 No.896 友達以上恋人未満
ユーザー firiexpfiriexp
提出日時 2019-09-27 23:00:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,306 ms / 3,500 ms
コード長 1,597 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 98,344 KB
実行使用メモリ 134,444 KB
最終ジャッジ日時 2024-04-27 02:56:42
合計ジャッジ時間 5,676 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 292 ms
36,152 KB
testcase_06 AC 419 ms
36,104 KB
testcase_07 AC 304 ms
36,016 KB
testcase_08 AC 295 ms
36,196 KB
testcase_09 AC 816 ms
68,792 KB
testcase_10 AC 2,306 ms
134,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]];
        cout << ans << "\n";
        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;
    }
    cout << anss << "\n";
    return 0;
}
0