結果

問題 No.183 たのしい排他的論理和(EASY)
コンテスト
ユーザー ともき
提出日時 2015-06-16 00:42:56
言語 Scala(Beta)
(3.8.1)
コンパイル:
scalac _filename_
実行:
java -cp .:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala3-library_3/3.8.1/scala3-library_3-3.8.1.jar:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala-library/3.8.1/scala-library-3.8.1.jar _class_
結果
AC  
実行時間 793 ms / 5,000 ms
コード長 528 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,676 ms
コンパイル使用メモリ 280,948 KB
実行使用メモリ 65,668 KB
最終ジャッジ日時 2026-03-09 13:25:43
合計ジャッジ時間 21,929 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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))
  }
}
0