結果
| 問題 |
No.896 友達以上恋人未満
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-27 21:42:19 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,071 bytes |
| コンパイル時間 | 2,330 ms |
| コンパイル使用メモリ | 78,148 KB |
| 実行使用メモリ | 202,568 KB |
| 最終ジャッジ日時 | 2024-09-24 21:08:15 |
| 合計ジャッジ時間 | 7,956 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 6 MLE * 1 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int M = sc.nextInt();
int N = sc.nextInt();
long mulX = sc.nextLong();
long addX = sc.nextLong();
long mulY = sc.nextLong();
long addY = sc.nextLong();
long MOD = sc.nextLong();
long[] z = new long[(int) MOD];
long[] x = new long[M];
long[] y = new long[M];
long[] a = new long[M];
long[] b = new long[M];
for (int i = 0; i < M; ++i) {
x[i] = sc.nextLong();
}
for (int i = 0; i < M; ++i) {
y[i] = sc.nextLong();
z[(int) x[i]] += y[i];
}
for (int i = 0; i < M; ++i) {
a[i] = sc.nextLong();
}
for (int i = 0; i < M; ++i) {
b[i] = sc.nextLong();
}
long curx = x[M - 1], cury = y[M - 1];
for (int i = M; i < N; ++i) {
curx = (curx * mulX + addX) & (MOD - 1);
cury = (cury * mulY + addY) & (MOD - 1);
z[(int) curx] += cury;
}
boolean[] isPrime = new boolean[(int) MOD];
Arrays.fill(isPrime, true);
isPrime[0] = false;
isPrime[1] = false;
for (int i = 2; i < isPrime.length; ++i) {
if (isPrime[i])
for (int j = 2 * i; j < isPrime.length; j += i)
isPrime[j] = false;
}
for (int i = 2; i < isPrime.length; ++i) {
if (!isPrime[i])
continue;
for (int j = (z.length - 1) / i; j >= 1; --j) {
z[j] += z[j * i];
}
}
long ans = 0;
for (int i = 0; i < M; ++i) {
long v = z2(a[i], z) - z2(a[i] * b[i], z);
System.out.println(v);
ans ^= v;
}
long cura = a[M - 1] & (MOD - 1), curb = b[M - 1] & (MOD - 1);
for (int i = M; i < N; ++i) {
cura = ((((cura * mulX) & (MOD - 1)) + addX + MOD - 1) & (MOD - 1)) + 1;
curb = ((((curb * mulY) & (MOD - 1)) + addY + MOD - 1) & (MOD - 1)) + 1;
long v = z2(cura, z) - z2(cura * curb, z);
ans ^= v;
}
System.out.println(ans);
}
long z2(long v, long[] z) {
if (v >= z.length)
return 0;
else
return z[(int) v];
}
void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}