結果

問題 No.939 and or
ユーザー er-k-aki
提出日時 2020-08-13 15:56:07
言語 Go
(1.23.4)
結果
TLE  
実行時間 -
コード長 857 bytes
コンパイル時間 11,230 ms
コンパイル使用メモリ 225,452 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-09 19:17:23
合計ジャッジ時間 17,017 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 TLE * 1
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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