#C11761. Next Email Date Calculation
Next Email Date Calculation
Next Email Date Calculation
You are given the current date and details of several customers. For each customer, you have their name, an interval (in days), and the date they last received an email. Your task is to compute the next date on which each customer should receive an email. The next email date is defined as the smallest date that can be expressed as
\( \text{last\_email\_date} + k \times \text{interval} \)
for some positive integer \( k \) such that the computed date is not earlier than the given current date.
Print the result for each customer on a new line in the format "CustomerName YYYY-MM-DD" in the same order as given.
inputFormat
The input is read from standard input (stdin) and has the following format:
T current_date_1 N1 name1 interval1 last_email_date1 name2 interval2 last_email_date2 ... (N1 lines) current_date_2 N2 name1 interval1 last_email_date1 ... (N2 lines) ... current_date_T NT ... (NT lines)
Where:
- T is the number of test cases.
- For each test case,
current_date
is a string in YYYY-MM-DD format. - N is the number of customers in the test case.
- Each customer line contains the customer's name (a string), the interval (an integer), and the last email date (in YYYY-MM-DD format), separated by spaces.
outputFormat
For each test case, output the computed next email date for each customer on a separate line to standard output (stdout). Each line should have the format:
CustomerName YYYY-MM-DD## sample
2
2023-10-01
3
Alice 30 2023-09-01
Bob 15 2023-09-20
Charlie 7 2023-09-24
2023-10-01
2
Dave 10 2023-09-28
Eve 5 2023-09-30
Alice 2023-10-01
Bob 2023-10-05
Charlie 2023-10-01
Dave 2023-10-08
Eve 2023-10-05
</p>