AtCoder Beginner Contest 183 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/abc183

A

Q_A.go


package main

import (
    "fmt"
)

func main() {
    var x int 
    fmt.Scanf("%d", &x)

    var ans int
    if x > 0{
        ans = x
    } else{
        ans = 0
    }
    fmt.Printf("%d\n", ans)
	
}

B

Q_B.go


package main

import (
	"fmt"
)

func main() {
    var S_x, S_y, G_x, G_y int
    fmt.Scanf("%d %d %d %d", &S_x, &S_y, &G_x, &G_y)
	
	var a float64
	a = float64(G_y + S_y) / float64(G_x - S_x)

	var ans float64
	ans = float64(S_y) / a + float64(S_x)

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

C

Q_C.go


package main

import (
	"fmt"
)

func remove(t []int, i int) []int {
	s := make([]int, len(t))

	copy(s, t)
    s[i] = s[len(s)-1]
    return s[:len(s)-1]
}

func greedy(n int, k int64, list []int, T [][]int64, now int) int{
	

	var num int = 0
	if n == 1{
		if T[now-1][0] == k{
			return 1
		} else {
			return 0
		}
	} else if  k<0{
		return 0
	}

	for i:=1; i<n; i++{
		next := list[i]
		var list_2 = remove(list, i)

		w := T[now-1][next-1]

		num += greedy(n-1, k-w, list_2, T, next)
	}

	return num
}

func main() {
	var N int
	var K int64
    fmt.Scanf("%d %d", &N, &K)

	T := make([][]int64, N)
	for i := 0; i < N; i++ {
		T[i] = make([]int64, N)
		for j:=0; j<N; j++{
			fmt.Scanf("%d", &T[i][j])
		}
	}

	List := make([]int, N)

	for i := 0; i < N; i++ {
		List[i] = i+1
	}

	ans := greedy(N, K, List, T, 1)

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

D If you remember, I will write it later.

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 182 Note
AtCoder Beginner Contest 183 Note
AtCoder Beginner Contest 184 Note
AtCoder Beginner Contest 188 Note
AtCoder Beginner Contest 179
AtCoder Beginner Contest 180
AtCoder Beginner Contest 173
Atcoder Beginner Contest 153
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 182 Review
AtCoder Beginner Contest 180 Review
AtCoder Beginner Contest 156 WriteUp
AtCoder Beginner Contest 177 Review
AtCoder Beginner Contest 168 Review
AtCoder Regular Contest 105 Note
Solve AtCoder Beginner Contest 100-102
AtCoder Beginner Contest 167 Memorandum
AtCoder Beginner Contest 172 Review
AtCoder Beginner Contest 176 Review
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 161 Participation Report
AtCoder Beginner Contest 151 Participation Report
AtCoder Beginner Contest 176 Participation Report
AtCoder Beginner Contest 153 Participation Report
AtCoder Beginner Contest # 002 C Problem
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
AtCoder Beginner Contest 158 Participation Report
AtCoder Beginner Contest 180 Participation Report
AtCoder Beginner Contest 156 Participation Report
AtCoder Beginner Contest 167 Participation Report
AtCoder Beginner Contest 179 Participation Report
AtCoder Beginner Contest 182 Participation Report
AtCoder Beginner Contest 146 Participation Report
AtCoder Beginner Contest 152 Participation Report