I tried Atcoder, so it's a memo for myself. I plan to add and correct it later.
https://atcoder.jp/contests/arc105
A
Q_A.go
package main
import (
"fmt"
)
func main() {
var a,b,c,d int
fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
flag := false
flag = (a == b+c+d || a+b == c+d || a+c == b+d || a+d == b+c || a+b+c == d || a+b+d == c || a+c+d == b )
var s string
if flag == true{
s = "Yes"
}else{
s = "No"
}
fmt.Printf("%s\n", s)
}
B
Q_B.go
package main
import (
"fmt"
)
func main() {
var N, a int
fmt.Scan(&N)
ans := 0
for i := 0; i < N; i++ {
fmt.Scan(&a)
ans = gcd(ans ,a)
}
fmt.Printf("%d\n", ans)
}
func gcd(a, b int) int {
if b == 0 {
return a
}
return gcd(b, a % b)
}
C If you remember, I will write it later.
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