Blame view

P35547_en/S001-AC.cc 612 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>

using namespace std;

int main()
{
	int k,x,b,c,q,p,y,z,n,e,D,M,Y;

	while(1)
	{
		cin >> Y;
		if(cin.eof())
		{
			return 0;
		}
		k = Y / 100;
		x = Y % 19;
		b = Y % 4;
		c = Y % 7;
		q = k / 4;
		p = (13 + 8*k) / 25;
		y = (15 - p + k - q) % 30;
		z = (19*x + y) % 30;
		n = (4 + k - q) % 7;
		e = (2*b + 4*c + 6*z + n) % 7;

		if(z + e <= 9)
		{
			D = 22 + z + e;
			M = 3;
		}
		else if(z == 29 && e == 6)
		{
			D = 19;
			M = 4;
		}
		else if(z == 28 && e == 6 && x > 10)
		{
			D = 18;
			M = 4;
		}
		else
		{
			D = z + e - 9;
			M = 4;
		}
		cout << D << "/" << M << endl;
	}
}