Friday the Thirteenth


/*
ID: tausiq11
PROG: friday
LANG: C++
*/

#include <stdio.h>

int main ()
{
	freopen ("friday.in", "r", stdin);
	freopen ("friday.out", "w", stdout);

	int year;

	scanf ("%d", &year);

	int days [] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int z = 3;
	int output [] = { 0, 0, 0, 0, 0, 0, 0 };

	for ( int i = 1900; i <= 1900 + year - 1; i++ ) {

		if ( ( i % 4 == 0 && i % 100 != 0 ) || ( i % 400 == 0 ) )
			days [1] = 29;
		else
			days [1] = 28;

		for ( int j = 1; j <= 12; j++ ) {
			for ( int k = 1; k <= days [j - 1]; ++k, z++ ) {
				
				if ( k == 13 ) {
					switch (z) {
					case 1:
						output [0]++;
						break;
					case 2:
						output [1]++;
						break;
					case 3:
						output [2]++;
						break;
					case 4: 
						output [3]++;
						break;
					case 5:
						output [4]++;
						break;
					case 6:
						output [5]++;
						break;
					case 7:
						output [6]++;
						break;
					}
				}

				if ( z == 7 )
					z = 0;
			}
		}
	}

	printf ("%d %d %d %d %d %d %d\n", output [0], output [1], output [2], output [3], output [4], output [5], output [6]);
	return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s