AtCoder Beginner Contest 184 Note

Preface

I tried Atcoder, so it's a memo for myself. I plan to add and correct it later.

problem

https://atcoder.jp/contests/abc184

A

Q_A.go


package main

import (
    "fmt"
)

func main() {
    var a, b, c, d int 
    fmt.Scanf("%d %d", &a, &b)
    fmt.Scanf("%d %d", &c, &d)

    ans := a * d - b * c

	fmt.Printf("%d\n", ans)
	
}

B

Q_B.go


package main

import (
	"fmt"
	"strings"
)

func main() {
    var N, X int
    fmt.Scanf("%d %d", &N, &X)
	
	var S string
    fmt.Scanf("%s", &S)

	result := strings.Split(S, "")

	for i:=0; i<N; i++{
		if result[i] == "o"{
			X += 1
		} else if X > 0{
			X -= 1
		}
	}

	fmt.Printf("%d\n", X)
	
}

C

Q_C.go


package main

import (
	"fmt"
	"math"
)

func main() {
    var r1, r2, c1, c2 int
    fmt.Scanf("%d %d", &r1, &c1)
    fmt.Scanf("%d %d", &r2, &c2)
	
	var ans int 

	if (r1 == r2) && (c1 == c2){
		ans = 0		
	} else if (r1+c1 == r2+c2) || (r1-c1 == r2-c2) || math.Abs(float64(r1-r2)) + math.Abs(float64(c1-c2)) <=3{
		ans = 1
  	} else if ((r2 - r1 + c2 - c1) % 2 == 0) || (math.Abs(float64(r2 - r1 - c2 + c1)) <= 3) || (math.Abs(float64(r2 - r1 + c2 - c1)) <= 3){
		ans = 2
	} else {
		ans = 3
	}

	fmt.Printf("%d\n", ans)
	
}

D

Q_D.go


package main

import (
	"fmt"
)

var dp [101][101][101]float64

//Recursive function that returns the expected value of the move
func f(a int, b int, c int) float64{
	//If you have already calculated
	if dp[a][b][c] != 0{
		return dp[a][b][c]
	}

	//If you have reached the goal, the expected value of movement is 0
	if (a == 100) || (b == 100) || (c == 100) {
		return 0
	} 

	var ans float64 = 0
	
	ans += (f(a+1, b, c) + 1) * float64(a) / float64(a + b + c)
	ans += (f(a, b+1, c) + 1) * float64(b) / float64(a + b + c)
	ans += (f(a, b, c+1) + 1) * float64(c) / float64(a + b + c)

	dp[a][b][c] = ans
	return ans

}

func main() {

	var A, B, C int
    fmt.Scanf("%d %d %d", &A, &B, &C)

	fmt.Printf("%f\n", f(A, B, C))

}

E If you remember, I will write it later.

F If you remember, I will write it later.

Recommended Posts

AtCoder Beginner Contest 181 Note
AtCoder Beginner Contest 187 Note
AtCoder Beginner Contest 180 Note
AtCoder Beginner Contest 182 Note
AtCoder Beginner Contest 183 Note
AtCoder Beginner Contest 184 Note
AtCoder Beginner Contest 188 Note
AtCoder Beginner Contest # 003 Participation Note
AtCoder Beginner Contest 177
AtCoder Beginner Contest 179
AtCoder Beginner Contest 172
AtCoder Beginner Contest 180
AtCoder Beginner Contest 173
Atcoder Beginner Contest 153
AtCoder Beginner Contest 152 Review
AtCoder Beginner Contest 160 Review
AtCoder Beginner Contest 178 Review
ACL Beginner Contest Note
AtCoder Beginner Contest 166 Review
AtCoder Beginner Contest 167 Review
AtCoder Regular Contest 106 Note
AtCoder Beginner Contest 164 Review
AtCoder Beginner Contest 169 Review
AtCoder Beginner Contest 181 Review
AtCoder Beginner Contest 171 Review
AtCoder Beginner Contest 180 Review
AtCoder Beginner Contest 156 WriteUp
AtCoder Beginner Contest 177 Review
AtCoder Regular Contest 105 Note
AtCoder Beginner Contest 179 Review
Solve AtCoder Beginner Contest 100-102
AtCoder Beginner Contest 167 Memorandum
AtCoder Beginner Contest 175 Review
AtCoder Beginner Contest 174 Review
AtCoder Beginner Contest 153 Review
AtCoder Beginner Contest 156 Review
AtCoder Beginner Contest 161 Review
AtCoder Beginner Contest 170 Review
AtCoder Beginner Contest 165 Review
AtCoder Beginner Contest 173 Review
AtCoder Beginner Contest 155 Review
AtCoder Beginner Contest 162 Review
AtCoder Beginner Contest 181 Participation Report
AtCoder Beginner Contest 175 Virtual entry
AtCoder Beginner Contest 161 Participation Report
AtCoder Beginner Contest 151 Participation Report
AtCoder Beginner Contest 154 Participation Report
AtCoder Beginner Contest 166 Participation Report
AtCoder Beginner Contest 153 Participation Report
AtCoder Beginner Contest # 002 C Problem
AtCoder Beginner Contest 145 Participation Report
AtCoder Beginner Contest 184 Participation Report
AtCoder Beginner Contest 165 Participation Report
AtCoder Beginner Contest 160 Participation Report
AtCoder Beginner Contest 169 Participation Report
AtCoder Beginner Contest 178 Participation Report
AtCoder Beginner Contest 163 Participation Report
AtCoder Beginner Contest 159 Participation Report
AtCoder Beginner Contest 164 Participation Report
AtCoder Beginner Contest 168 Participation Report
AtCoder Beginner Contest 150 Participation Report