Library Fine
Your local library needs your help! Given the expected and actual return dates for a library book, create a program that calculates the fine (if any). The fee structure is as follows: 1. If the book is returned on or before the expected return date, no fine will be charged (i.e.: fine = 0). 2. If the book is returned after the expected return day but still within the same calendar month and year as the expected return date, fine = 15 Hackos * (the number of days late). 3. If the book is r
View Solution →Max Transform
Transforming data into some other data is typical of a programming job. This problem is about a particular kind of transformation which we'll call the max transform. Let be a zero-indexed array of integers. For , let denote the subarray of from index to index , inclusive. Let's define the max transform of as the array obtained by the following procedure: Let be a list, initially empty. For from to : For from to : Let . Append to the end of . Return . The returned array
View Solution →Box Operations
Alice purchased an array of n wooden boxes that she indexed from 0 to n - 1 . On each box , she writes an integer that we'll refer to as . Alice wants you to perform q operations on the array of boxes. Each operation is in one of the following forms: (Note: For each type of operations, ) 1 l r c: Add to each . Note that can be negative. 2 l r d: Replace each with . 3 l r: Print the minimum value of any . 4 l r: Print the sum of all . Recall that is the maximum integer such tha
View Solution →Company Retreat
The LRT Company has employees. Each employee has a unique ID number from 1 to n , where the director's ID is number 1. Every employee in the company has exactly one immediate supervisor — except the director, who has no supervisor. The company's employee hierarchy forms a tree of employee IDs that's rooted at employee number (the director). The director decides to have a retreat lasting days. Each day, the employees will be assigned to different groups for team building exercises. Groups
View Solution →Find the permutation
Consider a permutation, , of integers from to . Let's determine the of to be the minimum absolute difference between any consecutive integers in : Generate a lexicographically sorted list of all permutations of length having a maximal distance between all permutations of the same length. Print the lexicographically permutation. Input Format The first line contains an integer, t (the number of test cases). The t subsequent lines each contain two space-separated integers, (the p
View Solution →