Code Exercise – BIQ-001
Mr.X owns a small business in a region with poor law-and-order. Recently his warehouse has been plagued by thieves. Gangs of thieves raid over his warehouse from time to time, stealing his raw material, affecting his business. He has studied the occurrances and noticed it that they are cyclical.
Assuming that a work week starts every Monday, and Sat and Sun are holidays, predict the total number of days when business would be affected.
Picture (Metafile) please see attached jpgeg
e.g. (Refer to Image) He has noticed that currently there seem to be 2 gangs. Gang1 raids every 4 days, whereas Gang2 strikes every 6 days.
Raids On Holidays are okay - since there is no raw material on those days. If more than gang raids the warehouse on a particular day, it is still counted as one bad day. So the answer in this case is 5.
Sample Input: (file)
The input is in the form of text file containing test cases.
3 4 8
The first line indicates the number of test cases - 2 above. Each test case is made up of 3 lines.
The first line of every test case indicates the number of gangs, n. (i.e 2 for TestCase#1)
The next line contains n integers, where each number k indicates that the gangi strikes every k days. (i.e. 4 and 6 for TestCase#1)
The next line is the number of days d, for which the prediction is needed. 0 <= d <= 365 (i.e. 21 days for TestCase#1)
Sample output: (can be printed to console.. via printf or equivalent)
Your program should accept the name of the input file (in the same dir) as a command line argument and print out the output of each test case on a new line.