結果

問題 No.896 友達以上恋人未満
ユーザー heno239heno239
提出日時 2019-09-27 22:24:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,546 ms / 3,500 ms
コード長 2,463 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 111,796 KB
実行使用メモリ 82,136 KB
最終ジャッジ日時 2023-10-24 23:37:48
合計ジャッジ時間 6,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 442 ms
37,080 KB
testcase_06 AC 731 ms
37,076 KB
testcase_07 AC 425 ms
37,080 KB
testcase_08 AC 423 ms
37,080 KB
testcase_09 AC 996 ms
69,848 KB
testcase_10 AC 1,546 ms
82,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
//const ll mod = 1000000007;
//const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

ll z[(1 << 24)+1];
int a[1000];
int b[1000];
int x[1000]; int y[1000];
int X[1000], Y[1000], A[1000], B[1000];
int m, n, mulx, addx, muly, addy, mod;
ll xsum=0;
void generate() {
	int prex, prey,prea,preb;
	rep(i, m) {
		x[i] = X[i];
		y[i] = Y[i];
		a[i] = A[i];
		b[i] = B[i];
		z[x[i]] += y[i];
	}
	prex = x[m - 1], prey = y[m - 1], prea = a[m - 1], preb = b[m - 1];
	Rep(i, m, n) {
		prex = ((ll)prex*mulx + addx) &(mod-1);
		prey = ((ll)prey*muly + addy)&(mod - 1);
		z[prex] += prey;
	}
	rep1(i, mod) {
		z[0] += z[i];
		for (int j = 2 * i; j < mod; j += i) {
			z[i] += z[j];
		}
		//cout <<"! "<< z[i] << endl;
	}
	Rep(i, m, n) {
		//cout << prea << " bef " << preb << endl;
		prea = (((ll)prea * mulx + addx + mod - 1)&(mod-1)) + 1;
		preb = (((ll)preb * muly + addy + mod - 1)&(mod - 1)) + 1;
		ll csum = z[prea];
		if ((ll)prea*preb <= mod)csum -= z[prea*preb];
		//cout << prea << " aft " << preb << endl;
		//cout << csum << endl;
		xsum ^= csum;
	}

}
void solve() {
	cin >> m >> n >> mulx >> addx >> muly >> addy >> mod;
	rep(i, m)cin >> X[i];
	rep(i, m)cin >> Y[i];
	rep(i, m)cin >> A[i];
	rep(i, m)cin >> B[i];
	generate();
	rep(i, m) {
		ll ans = z[a[i]];
		if ((ll)a[i] * b[i] <= mod) {
			ans -= z[a[i] * b[i]];
		}
		cout << ans << endl;
		xsum ^= ans;
	}

	cout << xsum << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//init();
	solve();
	//stop
	return 0;
}

0