結果

問題 No.896 友達以上恋人未満
ユーザー milanis48663220milanis48663220
提出日時 2019-09-28 00:54:22
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,337 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 57,248 KB
実行使用メモリ 108,372 KB
最終ジャッジ日時 2023-10-25 08:48:51
合計ジャッジ時間 7,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,512 KB
testcase_01 AC 2 ms
5,512 KB
testcase_02 AC 2 ms
5,512 KB
testcase_03 AC 2 ms
5,512 KB
testcase_04 AC 2 ms
5,516 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

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

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