結果

問題 No.896 友達以上恋人未満
ユーザー kotamanegikotamanegi
提出日時 2019-09-27 22:27:10
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 1,781 ms / 3,500 ms
コード長 2,699 bytes
コンパイル時間 1,363 ms
コンパイル使用メモリ 111,240 KB
実行使用メモリ 91,340 KB
最終ジャッジ日時 2023-08-20 12:58:12
合計ジャッジ時間 7,779 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,516 KB
testcase_01 AC 2 ms
5,516 KB
testcase_02 AC 2 ms
5,512 KB
testcase_03 AC 2 ms
5,560 KB
testcase_04 AC 2 ms
5,580 KB
testcase_05 AC 481 ms
48,472 KB
testcase_06 AC 1,049 ms
47,612 KB
testcase_07 AC 471 ms
47,676 KB
testcase_08 AC 457 ms
49,080 KB
testcase_09 AC 1,146 ms
80,956 KB
testcase_10 AC 1,781 ms
91,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long x[2001];
long long y[2001];
long long a[2001];
long long b[2001];
long long z[(1 << 24) + 1];
long long cnt[(1 << 21) + 1];
bool visited[(1 << 21) + 1];
long long mod;
long long calc_ans(long long now) {
	if (now < (1 << 20) && visited[now] == 1) {
		return cnt[now];
	}
	long long ans = 0;
	for (long long q = 1; now * q < mod; ++q) {
		ans += z[now * q];
	}
	if (now < 1 << 20) {
		visited[now] = 1;
		cnt[now] = ans;
	}
	return ans;
}
int main(){
#define int long long
	long long m, n, mulX, addX, mulY, addY;
	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];
	}
	long long now_x = x[m - 1];
	long long now_y = y[m - 1];
	long long now_a = a[m - 1];
	long long now_b = b[m - 1];
	for (int i = 0; i < n; ++i) {
		if (i < m) {
			now_x = x[i];
			now_y = y[i];
			now_a = a[i];
			now_b = b[i];
		}
		else {
			now_x = (now_x * mulX + addX) & (mod - 1);
			now_y = (now_y * mulY + addY) & (mod - 1);
			now_a = ((now_a * mulX + addX + mod - 1) & (mod - 1)) + 1;
			now_b = ((now_b * mulY + addY + mod - 1) & (mod - 1)) + 1;
		}
		z[now_x] += now_y;
	}
	long long final_go = 0;
	for (int i = 0; i < m; ++i) {
		now_x = x[i];
		now_y = y[i];
		now_a = a[i];
		now_b = b[i];
		long long hoge = calc_ans(now_a) - calc_ans(now_a * now_b);
		cout << hoge << endl;
		final_go ^= hoge;
	}
	for (int i = m; i < n; ++i) {
		now_x = (now_x * mulX + addX) & (mod - 1);
		now_y = (now_y * mulY + addY) & (mod - 1);
		now_a = ((now_a * mulX + addX + mod - 1) & (mod - 1)) + 1;
		now_b = ((now_b * mulY + addY + mod - 1) & (mod - 1)) + 1;
		long long hoge = calc_ans(now_a) - calc_ans(now_a * now_b);
		final_go ^= hoge;
	}
	cout << final_go << endl;
}
0