Archive / 2020 / February 2020
Full Moon Day
In a galaxy far, far away, there’s a planet named Planet-X. This planet has M months per year and D days per month. However, unlike planet Earth it has N number of moons. Each moon takes a different number of days (Xn) to orbit Planet-X. So, on this planet a day is called a Full Moon day, if all the moons get its lunar phase as Full Moon on that day. ( A lunar phase of a moon is the shape of the sunlit portion of the moon i.e. the visible portion of the moon )
Given a date of a full moon day(D1), your task is to find whether the 2nd date(D2) is a full moon day. If it’s not a full moon day, find C, the number of days to the closest full moon day.
Input Format
First line contains 3 integers, M, D & N.
Next line contains N integers, X1, X2, …, Xn
Next line contains 3 integers, y1, m1, d1. The year, month and date of D1 respectively.
Last line contains 3 integers, y2, m2, d2. The year, month and date of D2 respectively.
Output Format
If D2 is a Full Moon Day, print “FULL MOON DAY”.
If not, print a single positive integer C, the number of days to the closest full moon day.
Constraints
If the number of days between D1 & D2 is Z,
- 1 \(\leq\) M, D \(\leq\) 104
- 1 \(\leq\) N \(\leq\) 102
- 1 \(\leq\) Xn \(\leq\) M * 3
- 1 \(\leq\) Z \(\leq\) 108
- 1 \(\leq\) y1, y2 \(\leq\) 108
- 1 \(\leq\) m1, m2 \(\leq\) M
- 1 \(\leq\) d1, d2 \(\leq\) D
Limits
- Time Limit: 1s
- Memory Limit: 256MB
Sample Input 0
12 30 1
28
2019 12 10
2020 1 8
Sample Output 0
FULL MOON DAY
Sample Input 1
5 10 2
2 3
2019 1 1
2019 2 2
Sample Output 1
1
Open on HackerRank ↗ · Markdown source · Back to the archive