結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー yuki2006yuki2006
提出日時 2015-04-15 19:17:20
言語 Go
(1.22.1)
結果
RE  
実行時間 -
コード長 1,147 bytes
コンパイル時間 13,115 ms
コンパイル使用メモリ 223,468 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 10:27:08
合計ジャッジ時間 11,818 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"os"
	"strconv"
	"math/rand"
	"fmt"
	"strings"
)

func main() {
	N := nextInt()
	A := make([]int, N)

	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	var dp = make([]bool, 16384+1)

	dp[0] = true
	for i := 0; i < N; i++ {
		var nextDP = make([]bool, 16384+1)

		for k := 0; k <= 16384; k++ {
			if dp[k] {
				nextDP[k] = true
				nextDP[k^A[i]] = true

			}
		}
		dp = nextDP
	}
	var sum = 0
	for k := 0; k <= 16384; k++ {
		if dp[k] {
			sum++
		}
	}

	PrintI(sum)

}

var s = bufio.NewScanner(os.Stdin)

func next() string {

	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}
func nextLine() string {
	s.Split(bufio.ScanLines)
	s.Scan()
	if nil != s.Err() {
		panic(s.Err())
	}
	return s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}


func randInt(a int , b int) int {
	return rand.Intn(b - a + 1) + a
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}


func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}






0