Menu Close

Convert the travel days to years and months.

EXAMPLE PROBLEM

Johnson was working as a Captain of the Giant Ship. He was traveling from India to various countries around the world. The days of the travel may differ from one country to another.

To plan the upcoming travel the Johnson captain of the ship wold like to know the travel days in the year:month:day format.

Can you help Johnson?

Input:
Integer representing number days the ship was travelling.

Output:
Print the result in the prescribed format.
#include <stdio.h>
int main()
{
    int ndays,y,m,d;
    scanf("%d",&ndays);
    y=(int)ndays/365;
    ndays=ndays-(365*y);
    m=(int)ndays/30;
    d=(int)ndays-(m*30);
    printf("%d Y(s) %d M(s) %d D(s)",y,m,d);
	return 0;
}

INPUT_1:
8721

OUTPUT:
23  Y(s)  10  M(s)  26  D(s)


INPUT_2:
1000

OUTPUT:
2  Y(s)  9  M(s)  0  D(s)


INPUT_3:
10000

OUTPUT:
27  Y(s)  4  M(s)  25  D(s)



INPUT_4:
5000

OUTPUT:
13 Y(s) 8 M(s) 15 D(s)


INPUT_5:
9451

OUTPUT:
25 Y(s) 10 M(s) 26 D(s)


ILLUSTRATION

EXECUTED USING GCC LINUX

Morae Q!