PROBLEM LINK:Author: Hasan Jaddouh 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 nonnegative 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. AUTHOR'S AND TESTER'S SOLUTIONS:
This question is marked "community wiki".
asked 24 Nov '18, 23:56

PLEASE FIND THE BUG WOEKING FINE IN MY LOCAL MACHINE import java.util.; import java.lang.; import java.io.*; / Name of the class has to be "Main" only if the class is public. / class Codechef { private static Scanner mScanner=new Scanner(System.in); private static final String IMPOSSIBLE="impossible"; private static final String MANY="many"; public static void main (String[] args) throws java.lang.Exception
} answered 31 Jan, 00:20
