結果

問題 No.1665 quotient replace
ユーザー ks2mks2m
提出日時 2021-09-03 21:49:04
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 1,172 bytes
コンパイル時間 2,581 ms
コンパイル使用メモリ 78,384 KB
実行使用メモリ 994,488 KB
最終ジャッジ日時 2024-12-15 12:15:42
合計ジャッジ時間 231,291 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 2 MLE * 1
other TLE * 39 MLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int m = 1000001;
		List<List<Integer>> list = new ArrayList<>(m);
		for (int i = 0; i < m; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 2; i < m; i++) {
			for (int j = i * 2; j < m; j += i) {
				list.get(j).add(i);
			}
		}

		int[] g = new int[m];
		for (int i = 2; i < m; i++) {
			Set<Integer> set = new HashSet<>();
			for (int e : list.get(i)) {
				set.add(g[e]);
			}
			for (int j = 1; ; j++) {
				if (!set.contains(j)) {
					g[i] = j;
					break;
				}
			}
		}

		int x = 0;
		for (int i = 0; i < n; i++) {
			x ^= g[a[i]];
		}
		if (x == 0) {
			System.out.println("black");
		} else {
			System.out.println("white");
		}
	}
}
0