結果
問題 |
No.1665 quotient replace
|
ユーザー |
![]() |
提出日時 | 2021-09-09 09:14:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,432 bytes |
コンパイル時間 | 3,805 ms |
コンパイル使用メモリ | 114,344 KB |
実行使用メモリ | 132,448 KB |
最終ジャッジ日時 | 2024-12-29 12:26:56 |
合計ジャッジ時間 | 104,359 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 TLE * 23 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math; using System.Linq; using System.Collections.Generic; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); getAns(n, a); } static void getAns(int n, int[] a) { if (n == 1) { Console.WriteLine(a[0] == 1 ? "black" : "white"); return; } var s = GeneratePrime(1000000); var w = new int[n]; for (int i = 0; i < n; i++) w[i] = calc(a[i], s); var x = w[0] ^ w[1]; for (int i = 2; i < n; i++) x ^= w[i]; Console.WriteLine(x == 0 ? "black" : "white"); } static int calc(int t, List<int> s) { var p = 0; var count = 0; while (true) { if (t < s[p]) break; if (t % s[p] == 0) { t /= s[p]; count++; } else p++; } return count; } static List<int> GeneratePrime(int m) { var a = new List<int>(); int p; var sqrtMax = Sqrt(m); var s = Enumerable.Range(2, m - 1).ToList(); do { p = s.First(); a.Add(p); s.RemoveAll(n => n % p == 0); } while (p < sqrtMax); a.AddRange(s); return a; } }