結果

問題 No.896 友達以上恋人未満
ユーザー kotamanegikotamanegi
提出日時 2019-09-27 22:25:34
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,747 bytes
コンパイル時間 1,265 ms
コンパイル使用メモリ 147,172 KB
実行使用メモリ 78,080 KB
最終ジャッジ日時 2024-05-07 19:35:00
合計ジャッジ時間 5,555 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 443 ms
45,436 KB
testcase_06 AC 955 ms
45,440 KB
testcase_07 AC 461 ms
45,440 KB
testcase_08 AC 452 ms
45,312 KB
testcase_09 AC 1,115 ms
78,080 KB
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

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[1001];
long long y[1001];
long long a[1001];
long long b[1001];
long long z[(1 << 23) + 1];
long long cnt[(1 << 20) + 1];
bool visited[(1 << 20) + 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;
	iostream::sync_with_stdio(false);
	cin.tie(0);
	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