PROBLEM LINK:
Author: Hasan Jaddouh
Primary Tester: Amir Reza PoorAkhavan
Editorialist: Hussain Kara Fallah
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
Given the name of the day that some contest started at (Saturday, Sunday, Monday…), and the name of the day it was finished. You have to tell if the duration of the contest is some integer in the range [L, R].
If there’s no such number in the range output “none”.
If there’s one number in the range output this number.
If there’s more than one possible number in the range output “many”.
EXPLANATION:
The minimum possible duration of the contest is the difference in days between the name of the first day and the name of the second. Start with the day of start, and keep counting till you reach the other day. Let’s name this value D.
Now, what are the possible other values?
Clearly, It’s D + 7 * K, where K is an arbitrary non-negative integer (which means that it lasts for K extra full weeks). So we need to check how many values K makes our value D in the range [L,R]. This can be done with simple calculations, or maybe a loop since constraints are small.
Example:
Consider our sample was “Saturday Sunday 2 4”.
The minimum possible duration of the contest is 2.
Other possible values {9,16,23,30,…etc}.
Only 2 belongs to the interval thus the answer is 2.