Click Here to go back to the homepage.

Heliocentric Solution:


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

int main(){
    // #ifndef TESTING
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif 

    int earth, mars, caseNum = 1;
    while(cin >> earth >> mars){
        int ans = (365 - earth) % 365;
        earth = 0;
        mars += ans;
        if(mars != 687 && mars > 0){
            while(mars > 0){
                mars += 365;
                ans += 365;
                if(mars >= 687){
                    mars -= 687;
                }
            }

        }

        cout << "Case " << caseNum++ << ": " << ans << endl;
    }
    
    return 0;
}