結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー |
|
提出日時 | 2015-06-16 00:42:56 |
言語 | Scala(Beta) (3.6.2) |
結果 |
AC
|
実行時間 | 1,391 ms / 5,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 14,856 ms |
コンパイル使用メモリ | 256,924 KB |
実行使用メモリ | 63,908 KB |
最終ジャッジ日時 | 2024-12-16 01:47:11 |
合計ジャッジ時間 | 39,216 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
import scala.io.StdIn.readLine object Main{ def ipow(x : Integer,n : Integer) : Integer= if(x == n) 1 else if(n % 2 == 0) ipow(x*x,n/2) else x * ipow(x*x,n/2) def main(args: Array[String]) = { val n = readLine().toInt val a = readLine().split(" ").map(_.toInt).sorted.distinct val dp = Array.fill(ipow(2,15))(false) dp(0) = true for(ia <- a){ for(i <- 0 until dp.length){ dp(i ^ ia) = dp(i ^ ia) || dp(i) } } println(dp.count(_ == true)) } }