結果

問題 No.1665 quotient replace
ユーザー lanegue
提出日時 2021-09-05 01:33:39
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 795 ms / 3,000 ms
コード長 598 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 233,856 KB
実行使用メモリ 37,856 KB
最終ジャッジ日時 2024-06-22 12:20:15
合計ジャッジ時間 14,596 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;
void main(){
	auto n=readln.chomp.to!int;
	auto a=readln.chomp.split(" ").to!(int[]);
	auto p=[2];
	for(auto i=3; i<10^^3; i+=2){
		auto f=true;
		for(auto j=0; p[j]^^2<=i; j++){
			if(i%p[j]==0){
				f=false;
				break;
			}
		}
		if(f){
			p~=i;
		}
	}
	auto c=new int[n];
	for(auto i=0; i<n; i++){
		auto x=a[i];
		for(auto j=0; j<p.length;){
			if(x%p[j]==0){
				c[i]++;
				x/=p[j];
			}else{
				j++;
			}
		}
		if(x!=1){
			c[i]++;
		}
	}
	//stderr.writeln(c);
	auto r=c.reduce!((a,b) => a^b);
	stderr.writeln(r);
	if(r!=0){
		writeln("white");
	}else{
		writeln("black");
	}
}
0