結果
問題 |
No.183 たのしい排他的論理和(EASY)
|
ユーザー |
![]() |
提出日時 | 2021-05-17 18:45:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 434 ms / 5,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 1,552 ms |
コンパイル使用メモリ | 106,240 KB |
実行使用メモリ | 20,352 KB |
最終ジャッジ日時 | 2024-10-06 21:42:24 |
合計ジャッジ時間 | 5,121 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq; 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); a = a.Distinct().ToArray(); getAns(n, a); } static void getAns (int n, int [] a) { var imax = a.Max() * 2; var b = new bool[imax + 1]; b[0] = true; foreach (var x in a) { for (int i = imax ; i >= 0; i--) { if (b[i]) b[i ^ x] = true; } } var count = b.Count(x => x == true); Console.WriteLine(count); } }