コード例 #1
0
func Sqrt() {
	r := myio.NewReader()
	T, _ := strconv.Atoi(r.Read())
	for i := 0; i < T; i++ {
		n, _ := strconv.Atoi(r.Read())
		fmt.Printf("%f\n", mysqrt(float64(n)))
	}
}
コード例 #2
0
// MINCOUNT
func MoveToInvert() {
	r := myio.NewReader()
	T, _ := strconv.Atoi(r.Read())
	for i := 0; i < T; i++ {
		N, _ := strconv.Atoi(r.Read())
		fmt.Printf("%d\n", invTriangle(N))
	}

}
コード例 #3
0
func EditDistance() {
	r := myio.NewReader()
	T, _ := strconv.Atoi(r.Read())
	for i := 0; i < T; i++ {
		word0 := r.Read()
		word1 := r.Read()
		fmt.Printf("%d\n", editDist(word0, word1))
	}
}
コード例 #4
0
func Bitmap() {
	r := myio.NewReader()
	line := r.Read()
	T, _ := strconv.Atoi(line)
	for i := 0; i < T; i++ {
		bm := &Bitmapper{}
		answer := BitmapSolver(r, bm)
		fmt.Printf("%s", answer)
	}
}
コード例 #5
0
// Solve the problem of putting 15 tiles in order when you only have one blank space.
func FifteenNums() {
	r := myio.NewReader()
	T, _ := strconv.Atoi(r.Read())
	for i := 0; i < T; i++ {
		board := &Board{}
		board.Create(r)
		//PrintBoard(board.board)
		board.Solve()
	}
}
コード例 #6
0
// Solve the problem of putting 15 tiles in order when you only have one blank space.
func Sudoku() {
	r := myio.NewReader()
	board := &SudokuB{}
	board.Init()
	T, _ := strconv.Atoi(r.Read())
	for i := 0; i < T; i++ {
		board.Solve(r)
	}
	//PrintBoard(board.board)
	fmt.Println("End of sudoku program.")
	SudokuChecks()
}
コード例 #7
0
func linesFromFile() []string {
	// Read the board and save them as strings.
	r := myio.NewReader()
	num, _ := strconv.Atoi(r.Read())
	lines := []string{}
	for i := 0; i < num; i++ {
		chars := r.Read()
		fmt.Printf("%v\n", chars)
		lines = append(lines, chars)
	}
	return lines
}
コード例 #8
0
func GirlsBoys() {
	reader := myio.NewReader()
	for {
		line := reader.Read()
		if line == "0 0" {
			break
		}
		elements := strings.Split(line, " ")
		G, _ := strconv.Atoi(elements[0])
		B, _ := strconv.Atoi(elements[1])
		val := getMaxDivers(G, B)
		fmt.Printf("%d", val)
	}
}
コード例 #9
0
func Party() {
	r := myio.NewReader()
	for {
		line := r.Read()
		if line == "0 0" {
			break
		}
		numStrs := strings.Split(line, " ")
		budget, _ := strconv.Atoi(numStrs[0])
		numParties, _ := strconv.Atoi(numStrs[1])
		partier := &Partier{budget, numParties, r}
		fees, fun := partier.Solve()
		fmt.Printf("%d %d\n", fees, fun)
	}
}
コード例 #10
0
func GreatBall() {
	r := myio.NewReader()
	b := &GBaller{}
	T, _ := strconv.Atoi(r.Read())
	for i := 0; i < T; i++ {
		N, _ := strconv.Atoi(r.Read())
		b.Reset(N)
		for j := 0; j < N; j++ {
			els := strings.Split(r.Read(), " ")
			num0, _ := strconv.Atoi(els[0])
			num1, _ := strconv.Atoi(els[1])
			b.Process(num0, num1)
		}
		fmt.Printf("%d\n", b.Answer())
	}
}
コード例 #11
0
// MRECAMAN
func Recaman() {
	r := myio.NewReader()
	inputs := []int{}
	for {
		line := r.Read()
		input, _ := strconv.Atoi(line)
		if input == -1 {
			break
		}
		inputs = append(inputs, input)
		//fmt.Printf("%d\n", getRecaman(input))
	}
	rec := &Recmaner{}
	for _, input := range inputs {
		ans := rec.getRecaman(input)
		fmt.Printf("%d\n", ans)
	}
}