結果

問題 No.896 友達以上恋人未満
ユーザー milanis48663220milanis48663220
提出日時 2019-09-27 23:53:44
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,540 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 56,800 KB
実行使用メモリ 213,036 KB
最終ジャッジ日時 2023-10-25 07:39:19
合計ジャッジ時間 6,498 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,536 KB
testcase_01 AC 2 ms
5,536 KB
testcase_02 AC 2 ms
5,540 KB
testcase_03 AC 3 ms
5,536 KB
testcase_04 AC 2 ms
5,544 KB
testcase_05 AC 468 ms
71,084 KB
testcase_06 AC 763 ms
71,072 KB
testcase_07 AC 465 ms
71,084 KB
testcase_08 AC 485 ms
71,084 KB
testcase_09 AC 1,125 ms
135,988 KB
testcase_10 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

long z[(1<<24)+1];
long cnt[(1<<24)+1];
long x[1000], y[1000], a[1000], b[1000];

int main(){
    long M, N, mx, my, ax, ay, MOD;
    cin >> M >> N >> mx >> ax >> my >> ay >> MOD;
    for(long i = 0; i < M; i++){
        cin >> x[i];
    }
    for(long i = 0; i < M; i++){
        cin >> y[i];
    }
    for(long i = 0; i < M; i++){
        cin >> a[i];
    }
    for(long i = 0; i < M; i++){
        cin >> b[i];
        z[x[i]] += y[i];
    }
    long xp = x[M-1];
    long yp = y[M-1];
    for(long i = M; i < N; i++){
        long X, Y;
        X = xp*mx+ax;
        Y = yp*my+ay;
        X &= (MOD-1);
        Y &= (MOD-1);
        z[X] += Y;
        xp = X;
        yp = Y;
        //cout << X << ' ' << Y << endl;
    }
    for(long i = 1; i < MOD; i++){
        for(long j = 1; i*j < MOD; j++){
            cnt[i] += z[i*j];
        }
        //cout << cnt[i] << ' ';
    }
    //cout << endl;
    long xo = 0;
    for(long i = 0; i < M; i++){
        long ans = cnt[a[i]];
        if(a[i]*b[i] < MOD) ans -= cnt[a[i]*b[i]];
        //cout << a[i] << ' ' << b[i] << endl;
        cout << ans << endl;
        xo ^= ans;
    }
    long ap = a[M-1], bp = b[M-1];
    for(long i = M; i < N; i++){
        long A, B;
        A = ((ap*mx+ax+MOD-1)&(MOD-1))+1;
        B = ((bp*my+ay+MOD-1)&(MOD-1))+1;
        long ans = cnt[A];
        if(A*B < MOD) ans -= cnt[A*B];
       // cout << A << ' ' << B << endl;
        xo ^= ans;
        ap = A;
        bp = B;
    }
    cout << xo << endl;
}   
0