-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path10070.go
55 lines (48 loc) · 1.05 KB
/
10070.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// UVa 10070 - Leap Year or Not Leap Year and ...
package main
import (
"fmt"
"os"
)
func leapYear(year int) bool {
switch {
case year%4 != 0:
return false
case year%400 == 0:
return true
default:
return year%100 != 0
}
}
func huluculuYear(year int) bool { return year%15 == 0 }
func bulukuluYear(year int) bool { return leapYear(year) && year%55 == 0 }
func main() {
in, _ := os.Open("10070.in")
defer in.Close()
out, _ := os.Create("10070.out")
defer out.Close()
var year int
for first := true; ; {
if _, err := fmt.Fscanf(in, "%d", &year); err != nil {
break
}
if first {
first = false
} else {
fmt.Fprintln(out)
}
if leap, huluculu, bulukulu := leapYear(year), huluculuYear(year), bulukuluYear(year); !leap && !huluculu && !bulukulu {
fmt.Fprintln(out, "This is an ordinary year.")
} else {
if leap {
fmt.Fprintln(out, "This is leap year.")
}
if huluculu {
fmt.Fprintln(out, "This is huluculu festival year.")
}
if bulukulu {
fmt.Fprintln(out, "This is bulukulu festival year.")
}
}
}
}