I tried Atcoder, so it's a memo for myself. I plan to add and correct it later.
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