150 - Double Time

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

rickyliu
New poster
Posts: 30
Joined: Thu Sep 28, 2006 7:16 am

Post by rickyliu » Sat Dec 30, 2006 4:05 pm

Here are the testing input and the output from my AC program:
Input:

Code: Select all

Saturday 1 January 1600
Tuesday 1 January 1600
Tuesday 29 February 2000
Sunday 12 March 2000
Monday 13 March 2000
Tuesday 14 March 2000
Thursday 31 December 2099
Wednesday 31 December 2099
Saturday 29 August 1992
Saturday 16 August 1992
Wednesday 19 December 1991
Monday 1 January 1900
#
Output:

Code: Select all

Saturday 22* December 1599
Tuesday 11 January 1600
Tuesday 16* February 2000
Sunday 28* February 2000
Monday 29* February 2000
Tuesday 1* March 2000
Thursday 18* December 2099
Wednesday 13 January 2100
Saturday 16* August 1992
Saturday 29 August 1992
Wednesday 1 January 1992
Monday 20* December 1899
Lucas, maybe your have got AC. Anyway, your output in the second line differed with mine. Here is yours:

Code: Select all

Saturday 22* December 1599
Tuesday 10 January 1600       <-- this one differed
Tuesday 16* February 2000
Sunday 28* February 2000
Monday 29* February 2000
Tuesday 1* March 2000
Thursday 18* December 2099
Wednesday 13 January 2100
Saturday 16* August 1992
Saturday 29 August 1992
Wednesday 1 January 1992
Monday 20* December 1899
Hope this helps.

lantimilan
New poster
Posts: 11
Joined: Sat Mar 19, 2005 11:12 am
Location: HKU
Contact:

Just be careful

Post by lantimilan » Mon Dec 10, 2007 6:01 pm

Just got AC after three days struggle.
This problem takes extreme care, or maybe I am careless.

Check every boundary condition carefully, Feb 29, 1600, 1700, 2000 years, and when count from Dec 1899 to Jan 1900. Basically put some assert will help.
-- This is Unix, any explanatory error message is seen as a sign of weakness

rafastv
New poster
Posts: 22
Joined: Tue Jun 19, 2007 3:18 am

Re: 150 - Double Time

Post by rafastv » Fri Jul 28, 2017 4:19 pm

Hi, there, some tips for you:

1) Once you have a code that you think it is working, write a program to generate all possible dates between the range specified and check for negative numbers or zero.

2) Check for leap days, days between months and between years.

3) As said before, the first day in the Julian calendar is Friday 5 October 1582, which corresponds to Friday 15 October 1582 in the Gregorian calendar.

Good luck! This problem is quite fun, don't know why more people won't do it.

metaphysis
Experienced poster
Posts: 128
Joined: Wed May 18, 2011 3:04 pm

Re: 150 - Double Time

Post by metaphysis » Sun Feb 11, 2018 4:09 am

Test data generator.

Code: Select all

#include <iostream>

using namespace std;

const string months[12] = { "January", "February", "March", "April", "May",
    "June", "July", "August", "September", "October", "November", "December"
};

const string weekdays[7] = { "Monday", "Tuesday", "Wednesday", "Thursday",
    "Friday", "Saturday", "Sunday"
};

const int daysInMonth[2][12] = {
    {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};

int isLeapYear(int year, bool useOldFormat)
{
    return (useOldFormat ? year % 4 == 0 : (year % 400 == 0 || (year % 4 == 0
                && year % 100 != 0))) ? 1 : 0;
}

int main(int argc, char* argv[])
{
    int dayOfWeek = 5;
    for (int i = 1600; i <= 1601; i++)
        for (int j = 0; j < 12; j++)
            for (int k = 1; k <= daysInMonth[isLeapYear(i, false)][j]; k++)
            {
                cout << weekdays[dayOfWeek % 7] << " " << k << " " << months[j] << " " << i << "\n";
                dayOfWeek++;
            }
            
    cout << "#";
    
    return 0;
}

muazuicom22
New poster
Posts: 25
Joined: Tue Sep 11, 2018 10:32 pm

Post by muazuicom22 » Sat Sep 29, 2018 6:17 pm

CTY TDL CHUYÊN NHẬN LÀM GIẤY TỜ :

Kính gửi Quý khách hàng , Cty TDL chúng tôi

Nhận làm tất cả các loại giấy tờ liên quan đến BĐS , từ dễ đến khó , khu vực Thành Phố HCM Và Bình Dương.
* Vẽ thiết kế xây dựng, xin giấy phép xây dựng.
* Vẽ hiện trạng đo đạc nhà đất, nhà máy, nhà xưởng.
*Dịch vụ thiết kế Phòng cháy, chữa cháy và Thẩm duyệt.
* Dịch vụ xin chuyển mục đích sử dụng đất.
* Dịch vụ hoàn công nhà xưởng, công trình trên đất.
* Dịch vụ tách thửa sổ đỏ, nhà đất, nhà xưởng, nhà máy.
* Dịch vụ xin cấp mới sổ đỏ, sổ hồng hoặc xin cấp Giấy chứng nhận Quyền sử dụng đất, quyền sở hữu nhà ở và tài sản khác gắn liền với đất.
* Dịch vụ xác định lại ranh giới, thực trạng nhà đất, cấp sổ mới.
* Dịch vụ xem xét lại quy hoạch xây dựng.
* Dịch vụ hợp thức hóa nhà đất.
* Dịch vụ sang tên , đăng bạ sang tên chủ quyền, thừa kế di chúc.


Ai có nhu cầu liên hệ 0938.242.835 c.Hong.
Quý khách Lưu lại khi cần . Trân trọng cảm ơn. Uy Tin_ chinh chuan.
Chúc Anh chị một ngày tốt lành

Post Reply

Return to “Volume 1 (100-199)”