結果

問題 No.896 友達以上恋人未満
コンテスト
ユーザー zengyongxu-jerry
提出日時 2026-08-25 21:10:34
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,425 ms / 3,500 ms
+ 191µs
コード長 1,514 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,723 ms
コンパイル使用メモリ 351,108 KB
実行使用メモリ 81,920 KB
最終ジャッジ日時 2026-08-25 21:10:44
合計ジャッジ時間 9,469 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define rep(i, x, y) for (int i = (x); i <= (y); i ++ )
#define per(i, x, y) for (int i = (x); i >= (y); i -- )
const int N = 1e3 + 5, M = 1e6 + 5;
const int inf = 1e9;
const ll INF = 1e18, RMX = 2324814;
mt19937 rd(time(0));
uniform_int_distribution<int> dist(0, RMX);

int m, n;
ll mulx, addx, muly, addy, mod;
ll x[N], y[N], a[N], b[N];
ll cnt[1 << 24];

signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    cin >> m >> n >> mulx >> addx >> muly >> addy >> mod;
    rep(i, 1, m) cin >> x[i];
    rep(i, 1, m) cin >> y[i];
    rep(i, 1, m) cin >> a[i];
    rep(i, 1, m) cin >> b[i];
    
    rep(i, 1, m) cnt[x[i]] += y[i];
    
    ll nowx = x[m], nowy = y[m];
    rep(i, m + 1, n){
		nowx = (1ll * mulx * nowx + addx) % mod;
		nowy = (1ll * muly * nowy + addy) % mod;
		cnt[nowx] += nowy;
	}
	
	rep(i, 1, mod - 1) for (int j = i + i; j < mod; j += i) cnt[i] += cnt[j];
	
	ll qwq = 0;
	rep(i, 1, m){
		ll res = 0;
		if (a[i] < mod) res += cnt[a[i]];
		if (a[i] * b[i] < mod) res -= cnt[a[i] * b[i]];
		cout << res << "\n", qwq ^= res;
	}
	ll nowa = a[m], nowb = b[m];
	rep(i, m + 1, n){
		nowa = (1ll * mulx * nowa + addx + mod - 1) % mod + 1;
		nowb = (1ll * muly * nowb + addy + mod - 1) % mod + 1;
		ll res = 0;
		if (nowa < mod) res += cnt[nowa];
		if (nowa * nowb < mod) res -= cnt[nowa * nowb];
		qwq ^= res;
	}
	cout << qwq << "\n";
}
0