 # CODEO6 - Editorial

Practic

Contest

DIFFICULTY

Easy-Medium

PROBLEM

In this problem we are given a date based on a new type of calendar with it’s own division of days(20 days (called Alpha) in a Beta, 18 Betas in a Gamma, 20 Gammas in a Delta and 20 Deltas in a Epsilon) For this date based on the new calendar we have to print the date based on our own Georgian calendar.

EXPLANATION

The date input is in reverse ie, the first number is Epsilon, the second Number is Delta, the third is Gamma, fourth is Beta and fifth is Alpha. We read the numbers one by one and calculate the total number of days from 13 20 7 16 3 (Since this is the first day of the new calendar). To count the number of days, the code is as follows-

``````scanf("%d",&x);
Ndays += 20L * 20L * 18L * 20L * (x - 13L);
scanf("%d",&x);
Ndays += 20L * 18L * 20L * (x - 20L);
scanf("%d",&x);
Ndays += 18L * 20L * (x - 7L);
scanf("%d",&x);
Ndays += 20L * (x - 16L);
scanf("%d",&x);
Ndays += (x - 3L);
``````

Now that we have the number of days, we now have to count the total number of years, months and days of the Georgian calendar this number of days comprises of. We loop through increasing months and years while we decrease the number of days gradually. At the end the number of dayys leaf (which is < 31) will be the date. The code is as follows-

``````do
{
if( Ndays >= 31 ) { Ndays -= 31; Month++; }			/* Jan */
if( Year % 4 == 0 ) {
if( Ndays >= 29 ) { Ndays -= 29; Month++; }		/* Feb in leap year */
} else {
if( Ndays >= 28 ) { Ndays -= 28; Month++; }		/* Feb not in leap year */
}
if( Ndays >= 31 ) { Ndays -= 31; Month++; }			/* Mar */
if( Ndays >= 30 ) { Ndays -= 30; Month++; }			/* Apr */
if( Ndays >= 31 ) { Ndays -= 31; Month++; }			/* May */
if( Ndays >= 30 ) { Ndays -= 30; Month++; }			/* Jun */
if( Ndays >= 31 ) { Ndays -= 31; Month++; }			/* Jul */
if( Ndays >= 31 ) { Ndays -= 31; Month++; }			/* Aug */
if( Ndays >= 30 ) { Ndays -= 30; Month++; }			/* Sept */
if( Ndays >= 31 ) { Ndays -= 31; Month++; }			/* Oct */
if( Ndays >= 30 ) { Ndays -= 30; Month++; }			/* Nov */
if( Ndays >= 31 ) { Ndays -= 31; Month = 1; Year++; }			/* Dec */
}
while( Ndays >= 31 );
``````

AUTHOR’S SOLUTION

Author’s solution can be found here

//