結果

問題 No.896 友達以上恋人未満
ユーザー Y17Y17
提出日時 2019-09-27 23:01:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,427 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 159,560 KB
実行使用メモリ 11,920 KB
最終ジャッジ日時 2023-10-25 05:41:54
合計ジャッジ時間 11,337 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘long long int make()’:
main.cpp:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^

ソースコード

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];

int 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