結果

問題 No.896 友達以上恋人未満
ユーザー Y17Y17
提出日時 2019-09-27 23:15:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,968 ms / 3,500 ms
コード長 1,427 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 167,976 KB
実行使用メモリ 82,092 KB
最終ジャッジ日時 2023-10-25 06:21:09
合計ジャッジ時間 9,790 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 802 ms
37,036 KB
testcase_06 AC 1,737 ms
37,016 KB
testcase_07 AC 792 ms
37,036 KB
testcase_08 AC 801 ms
37,036 KB
testcase_09 AC 1,421 ms
69,168 KB
testcase_10 AC 1,968 ms
82,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

int m, n, mulx, addx, muly, addy, MOD;

int z[(1 << 24)] = {};
int x[1010];
int y[1010];
int a[1010];
int b[1010];

void make(){
    int xx = 0;
    int yy = 0;
    for(int i = 0;i < m;i++){
        xx = x[i];
        yy = y[i];
        z[xx] += yy;
    }

    for(int i = m;i < n;i++){
        xx = (xx * mulx + addx) % MOD;
        yy = (yy * muly + addy) % MOD;
        z[xx] += yy;
    }

    for(int i = 1;i < MOD;i++){
        for(int j = i*2;j < MOD;j+=i){
            z[i] += z[j];
        }
    }

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    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];
    make();

    int xans = 0;
    for(int i = 0;i < m;i++){
        int ans = z[a[i]];
        if(a[i] * b[i] < MOD){
            ans -= z[a[i] * b[i]];
        }
        cout << ans << endl;
        xans ^= ans;
    }

    int aa = a[m-1], bb = b[m-1];
    for(int i = m;i < n;i++){
        aa = (aa * mulx + addx + MOD -1) % MOD + 1;
        bb = (bb * muly + addy + MOD -1) % MOD + 1;

        int ans = z[aa];
        if(aa * bb < MOD){
            ans -= z[aa * bb];
        }


        xans ^= ans;
    }

    cout << xans << endl;

    return 0;
}
0