## Algorithm

Problem Name: beecrowd | 2139

# Pedrinho's Christmas

By Joao Marcos Salvanini Bellini de Moraes, IFSULDEMINAS Brazil

Timelimit: 1

Pedrinho is a boy who loves family parties, especially Christmas, when he wins gifts from his parents and grandparents. This year, his father promised him a PS4, but only if Pedrinho could solve some challenges throughout the year, one of them, writing a program that calculates how many days are left until Christmas.

However, Pedrinho is only 9 years old and knows nothing about programming, but he knows that you, his cousin, mess with "computer stuff" and thus, he asked you to write the program for him. Not only that, but he promised to let you play every weekend and for how long you would like to.

## Input

The input consists of several test cases. Each line contains the month and the day of the year 2016 (leap year). Read input until EOF.

## Output

If it's Christmas, print "E natal!"; if it's Christmas Eve, print "E vespera de natal!"; if it has already passed, print "Ja passou!". Otherwise, print "Faltam X dias para o natal!", being X the number of days left until Christmas.

 Input Sample Output Sample 12 24 11 24 12 29 1 5 12 25 E vespera de natal! Faltam 31 dias para o natal! Ja passou! Faltam 355 dias para o natal! E natal!

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````
#include <stdio.h>

int main(void)
{
int days[12]={31, 29, 31, 30, 31 ,30, 31, 31, 30, 31, 30, 31};
int i, m, d, x, y;

while (scanf("%i %i", &m, &d) != EOF)
{
if (m==12)
x=25-d;

else
{
x=days[m-1]-d;

for (i = m; i  <  11; ++i)
x+=days[i];

x+=25;
}

if (x==0)
printf("E natal!\n");

else if (x==1)
printf("E vespera de natal!\n");

else if (x < 0)
printf("Ja passou!\n");

else
printf("Faltam %i dias para o natal!\n", x);
}

return 0;
}
``````
Copy The Code &

Input

cmd
12 24 11 24 12 29 1 5 12 25

Output

cmd
E vespera de natal! Faltam 31 dias para o natal! Ja passou! Faltam 355 dias para o natal! E natal!

### #2 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include<stdio.h>

int main()
{
int month,day,ar[12]= {31,29,31,30,31,30,31,31,30,31,30,25},x,i;

while(scanf("%d %d",&month,&day)!=EOF)
{
if(month==12 && day ==25)printf("E natal!\n");
else if(month==12 && day ==24)printf("E vespera de natal!\n");
else if(month==12 && day > 25)printf("Ja passou!\n");
else
{
x = ar[month-1] - day;

for(i = month ; i < 12 ; i++)
{
x=x+ar[i];
}
printf("Faltam %d dias para o natal!\n",x>;
}
x=0;
}

return 0;
}
``````
Copy The Code &

Input

cmd
12 24 11 24 12 29 1 5 12 25

Output

cmd
E vespera de natal! Faltam 31 dias para o natal! Ja passou! Faltam 355 dias para o natal! E natal!

### #3 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var prompt = function(texto) { return lines.shift();};

const monthsInDays = {
1: 0,
2: 31,
3: 60,
4: 91,
5: 121,
6: 152,
7: 182,
8: 213,
9: 244,
10: 274,
11: 305,
12: 335,
};

while (true) {
var input = prompt().split("");
if (isNaN(input[0])) {
break;
}
input = input.join("");

var [month, days] = input.split(" ").map(Number);
var totalDays = monthsInDays[month] + days;
var daysLeft = 360 - totalDays;

if (daysLeft  <  0) {
console.log("Ja passou!");
}
if (daysLeft == 0) {
console.log("E natal!");
}
if (daysLeft == 1) {
console.log("E vespera de natal!");
}
if (daysLeft > 1) {
console.log("Faltam " + daysLeft + " dias para o natal!");
}
}

``````
Copy The Code &

Input

cmd
12 24 11 24 12 29 1 5 12 25

Output

cmd
E vespera de natal! Faltam 31 dias para o natal! Ja passou! Faltam 355 dias para o natal! E natal!