AtCoder Beginner Contest 189のメモ
前置き
Atcoderをやってみたので、自分用のメモです。
あとから加筆・修正する予定です。
問題
A
Q_A.go
package main
import (
"fmt"
"strings"
)
func main() {
var C string
fmt.Scanf("%s", &C)
s := strings.Split(C, "")
var flag bool = true
var c string = s[0]
for i:=1; i<3; i++{
if c != s[i]{
flag = false
}
}
if flag{
fmt.Printf("Won\n")
} else {
fmt.Printf("Lost\n")
}
}
B
Q_B.go
package main
import (
"fmt"
)
func main() {
var N int
var X int64
fmt.Scanf("%d %d", &N, &X)
X = X*100
var alcohole int64 = 0
var v, p int64
var ans int = -1
for i:=0; i<N; i++{
fmt.Scanf("%d %d", &v, &p)
alcohole += v * p
if alcohole > X {
ans = i + 1
break
}
}
fmt.Printf("%d\n", ans)
}
C
Q_C.go
package main
import (
"fmt"
)
func main() {
var N int64
fmt.Scanf("%d", &N)
A := make([]int64, N)
var i int64
for i=0; i<N; i++{
fmt.Scanf("%d", &A[i])
}
var mikan int64 = 0
var max, min int64
var l,r int64
for l=0; l<N; l++{
min = A[l]
for r=l; r<N; r++{
if A[r] < min {
min = A[r]
}
max = min * (r - l + 1)
if max > mikan {
mikan = max
}
}
}
fmt.Printf("%d\n", mikan)
}
D
Q_D.go
package main
import (
"fmt"
)
func dfs(S []string, N int, i int) int64{
var count int64 = 0
if i == 0{
return 1
}
count += dfs(S, N, i-1)
if S[i] == "OR"{
var c int64 = 1
for j:=0; j<i; j++{
c = c * 2
}
count += c
}
return count
}
func main() {
var N int
fmt.Scanf("%d", &N)
S := make([]string, N+1) // AND/OR
for i:=1; i<=N; i++{
fmt.Scanf("%s", &S[i])
}
var count int64 = 0
count += dfs(S, N, N)
fmt.Printf("%d\n", count)
}
E
Q_A.go
package main
import (
"fmt"
"strings"
)
func main() {
var C string
fmt.Scanf("%s", &C)
s := strings.Split(C, "")
var flag bool = true
var c string = s[0]
for i:=1; i<3; i++{
if c != s[i]{
flag = false
}
}
if flag{
fmt.Printf("Won\n")
} else {
fmt.Printf("Lost\n")
}
}
Q_B.go
package main
import (
"fmt"
)
func main() {
var N int
var X int64
fmt.Scanf("%d %d", &N, &X)
X = X*100
var alcohole int64 = 0
var v, p int64
var ans int = -1
for i:=0; i<N; i++{
fmt.Scanf("%d %d", &v, &p)
alcohole += v * p
if alcohole > X {
ans = i + 1
break
}
}
fmt.Printf("%d\n", ans)
}
C
Q_C.go
package main
import (
"fmt"
)
func main() {
var N int64
fmt.Scanf("%d", &N)
A := make([]int64, N)
var i int64
for i=0; i<N; i++{
fmt.Scanf("%d", &A[i])
}
var mikan int64 = 0
var max, min int64
var l,r int64
for l=0; l<N; l++{
min = A[l]
for r=l; r<N; r++{
if A[r] < min {
min = A[r]
}
max = min * (r - l + 1)
if max > mikan {
mikan = max
}
}
}
fmt.Printf("%d\n", mikan)
}
D
Q_D.go
package main
import (
"fmt"
)
func dfs(S []string, N int, i int) int64{
var count int64 = 0
if i == 0{
return 1
}
count += dfs(S, N, i-1)
if S[i] == "OR"{
var c int64 = 1
for j:=0; j<i; j++{
c = c * 2
}
count += c
}
return count
}
func main() {
var N int
fmt.Scanf("%d", &N)
S := make([]string, N+1) // AND/OR
for i:=1; i<=N; i++{
fmt.Scanf("%s", &S[i])
}
var count int64 = 0
count += dfs(S, N, N)
fmt.Printf("%d\n", count)
}
E
Q_C.go
package main
import (
"fmt"
)
func main() {
var N int64
fmt.Scanf("%d", &N)
A := make([]int64, N)
var i int64
for i=0; i<N; i++{
fmt.Scanf("%d", &A[i])
}
var mikan int64 = 0
var max, min int64
var l,r int64
for l=0; l<N; l++{
min = A[l]
for r=l; r<N; r++{
if A[r] < min {
min = A[r]
}
max = min * (r - l + 1)
if max > mikan {
mikan = max
}
}
}
fmt.Printf("%d\n", mikan)
}
Q_D.go
package main
import (
"fmt"
)
func dfs(S []string, N int, i int) int64{
var count int64 = 0
if i == 0{
return 1
}
count += dfs(S, N, i-1)
if S[i] == "OR"{
var c int64 = 1
for j:=0; j<i; j++{
c = c * 2
}
count += c
}
return count
}
func main() {
var N int
fmt.Scanf("%d", &N)
S := make([]string, N+1) // AND/OR
for i:=1; i<=N; i++{
fmt.Scanf("%s", &S[i])
}
var count int64 = 0
count += dfs(S, N, N)
fmt.Printf("%d\n", count)
}
E
覚えてたら後で書きます。
F
覚えてたら後で書きます。
Author And Source
この問題について(AtCoder Beginner Contest 189のメモ), 我々は、より多くの情報をここで見つけました https://qiita.com/nogawanogawa/items/7e4907cfdb2061529dd3著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .