-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy path10193.go
More file actions
38 lines (33 loc) · 683 Bytes
/
10193.go
File metadata and controls
38 lines (33 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// UVa 10193 - All You Need Is Love
package main
import (
"fmt"
"os"
"strconv"
)
func gcd(a, b int64) int64 {
if b == 0 {
return a
}
return gcd(b, a%b)
}
func main() {
in, _ := os.Open("10193.in")
defer in.Close()
out, _ := os.Create("10193.out")
defer out.Close()
var n int
var num string
fmt.Fscanf(in, "%d", &n)
for i := 1; i <= n; i++ {
fmt.Fscanf(in, "%s", &num)
num1, _ := strconv.ParseInt(num, 2, 64)
fmt.Fscanf(in, "%s", &num)
num2, _ := strconv.ParseInt(num, 2, 64)
if fmt.Fprintf(out, "Pair #%d: ", i); gcd(num1, num2) == 1 {
fmt.Fprintln(out, "Love is not all you need!")
} else {
fmt.Fprintln(out, "All you need is love!")
}
}
}