package main import ( "bufio" "fmt" "os" "strconv" "strings" ) var sc = bufio.NewScanner(os.Stdin) func main() { A, B := GetTwoInts() fmt.Println(exploreCorrectBitPairCount(A, B)) } //条件を満たす整数組の個数を返す func exploreCorrectBitPairCount(A int, B int) int { count := 0 // A= 000011111 // B= 111100000 // |= 111111111 limit := A | B for Y := 0; Y <= limit; Y++ { //X<=Y for X := 0; X <= Y; X++ { if X&Y == A && X|Y == B { count++ } } } return count } func NextLine() string { sc.Scan() return sc.Text() } func NextInt() int { a, _ := strconv.Atoi(NextLine()) return a } /** * スペース区切りで文字列を受け取って整数を2個返す */ func GetTwoInts() (a int, b int) { str := strings.Split(NextLine(), " ") a, _ = strconv.Atoi(str[0]) b, _ = strconv.Atoi(str[1]) return }