Editorial for UnVigil II: The Squeakquel


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Editorialist: PHPeasant

A simple piece of modular arithmetic will give you the answer. The only possible trick is reading the months correctly (there are 13 of them and they are not all standard).

An example solution in C++14 is given below

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string months[13] = {"January", "February",
                         "March", "April",
                         "May", "June",
                         "July", "August",
                         "September", "Spooktober",
                         "November", "December",
                         "January2"};
    string month;
    int k, next_month;
    cin >> month >> k;
    for(int i = 0; i < 13; ++i){
        if(month == months[i]){
            next_month = (i+k)%13;
        }
    }
    cout << months[next_month];
    return 0;
}

Comments

There are no comments at the moment.