Pony wants to play!
Time limit0.25sMemory limit1024 MB
Given today's weekday K and integers A, B, C, find the weekdays A^(B^C) and B^C/A days later, then count how many of them match the claimed weekday L.
- Level
Medium4 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Twin and Pony are quizzing each other.
- Pony: If today is Monday, what day is it days from now?
- Twin: Saturday!
- Pony: Then what about days later?
- Twin: Um... Friday?
- Pony: Then what day is it days later? What about days later?
- Twin: Are you kidding me??
Annoyed by the joke, Twin walked home in the middle of the quiz. Before leaving, Twin heard the answers and now wants to know how Pony solved them so fast.
For Twin, write a program that takes today's weekday and finds the weekday days later and the weekday days later. It should also check whether Pony's answer is correct.
Weekdays are numbered as follows: Monday is , Tuesday is , Wednesday is , Thursday is , Friday is , Saturday is , and Sunday is .
Input
The first line contains integers , , and . (, , is a multiple of )
The second line contains integers and . ()
Output
If today is weekday and both the date days later and the date days later fall on weekday , print . Otherwise, if only the date days later falls on weekday , print . If only the date days later falls on weekday , print . If neither date falls on weekday , print .