631 - Microzoft Calendar
Posted: Sat Jul 13, 2002 12:32 pm
I can't solve this problem. As I see, it's not so hard, but all my attempts to get AC failed
. Could anyone tell me, what's wrong with the problem?

Bates-Sun-Second-4-399bdCaesum wrote:Can anyone give the output for:
1600-01-01
5000-12-31
Code: Select all
1998-06-19
1997-06-26
1997-06-25
1997-06-24
1600-01-01
1754-12-31
2476-12-04
4444-04-12
END
Code: Select all
Bates-Money-Sixth-6-1bd
Gill-Sun-First-2-1bd
Gill-Sun-First-1-1bd
Feast 5-2bd
Bates-Sun-Fourth-3-399bd
Bates-Sun-Second-4-244bd
Gill-Money-Fourth-2-479
Bates-Mountains-First-5-2446
Code: Select all
Bates-Money-Sixth-6-1bd
Gill-Sun-First-2-1bd
Gill-Sun-First-1-1bd
Feast 5-2bd
Bates-Sun-Second-4-399bd
Bates-Sun-Second-4-244bd
Gill-Money-Fourth-2-479
Bates-Mountains-First-5-2446
I assumed, that leap years before doors are 4bd, 8bd, 12bd, ... and I got AC.sluga wrote:Which years before doors are considered leap? Those like 4bd or those like 5bd? I am asking because for example, 5bd is 8 years before 4, which is a leap year.
Code: Select all
#include <iostream>
using namespace std;
bool isLeapYear(int yyyy)
{
return ((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0);
}
int main(int argc, char *argv[])
{
for (int i = 1600; i <= 5000; i += 100)
{
for (int j = 1; j <= 12; j++)
{
if (j == 2)
{
for (int k = 1; k <= 28; k++)
{
cout << i << "-02-";
if (k < 10) cout << '0';
cout << k << '\n';
}
if (isLeapYear(i)) cout << i << "-02-29\n";
}
else
{
for (int k = 1; k <= 30; k++)
{
cout << i << '-';
if (j < 10) cout << '0';
cout << j << '-';
if (k < 10) cout << '0';
cout << k << '\n';
}
if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 || j == 12)
{
cout << i << '-';
if (j < 10) cout << '0';
cout << j << "-31\n";
}
}
}
}
cout << "END\n";
return 0;
}