AtCoder Beginner Contest 180 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/abc180

A

Q_A.go


package main

import (
    "fmt"
)

func main() {
    var n, a, b int
    fmt.Scanf("%d %d %d", &n,&a,&b)
	
    fmt.Printf("%d\n", n-a+b)
}

B

Q_B.go


package main

import (
	"fmt"
	"math"
)

func main() {
    var n int
    fmt.Scanf("%d", &n)
	
	var t int
	manhattan :=0
	euqulid :=0
	chebishev :=0

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &t)
		
		if t > 0 {
			manhattan += t
		}else{
			manhattan -= t
		}

		euqulid += t*t

		if t > 0 {
			if t > chebishev{
				chebishev = t
			}
		}else{
			if -t > chebishev{
				chebishev = -t				
			}  
		}
	}

	fmt.Printf("%d\n", manhattan)
	
    fmt.Printf("%.10f\n", math.Sqrt(float64(euqulid)))
	
	fmt.Printf("%d\n", chebishev)
	
}

C

Q_C.go


package main

import (
	"fmt"
)

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

	max := make([]int, 1)

	for i:=1; i*i<n+1; i++{
		if n % i == 0{
			if n/i != i{
				max = append(max, n/i)
			}
			fmt.Printf("%d\n", i)
		}
	}


	for i:=len(max)-1; i>0; i--{
		if max[i] != 0{
			fmt.Printf("%d\n", max[i])
		}
	}
}

D

Q_D.go


package main

import (
    "fmt"
)

func main() {
    var x, y, a, b uint64
    fmt.Scanf("%d %d %d %d", &x, &y, &a, &b)

	var cnt uint64 = 0

	for x < y/a & b/(a-1) {
		cnt++
		x *= a
	}

	cnt += (y-1-x)/b

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

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 179
AtCoder Beginner Contest 172
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
AtCoder Beginner Contest 179 Review
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 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