#P7075. [CSP-S 2020] 儒略日

[CSP-S 2020] 儒略日

Description

To make calculations easier, astronomers use the Julian day (Julian day) to represent time. A Julian day is defined as the number of days that have passed from 12:00 noon on January 1, 4713 BC to some later moment. If it is less than one full day, it is written as a decimal. With this astronomical calendar, every moment is mapped evenly onto a number line, so it is convenient to compute differences between times.

Now you are given a Julian day with no fractional part. Please compute the corresponding Gregorian calendar date for that Julian day (it must be 12:00 noon of some day).

The calendar we use today is the Gregorian calendar. It was introduced in AD 1582 by Pope Gregory XIII as a modification of the earlier Julian calendar (note: the Julian calendar is not directly related to the Julian day). Specifically, dates are determined by the following rules:

  1. On and after October 15, 1582 (inclusive): use the Gregorian calendar. The number of days in each month is: January 3131 days, February 2828 or 2929 days, March 3131 days, April 3030 days, May 3131 days, June 3030 days, July 3131 days, August 3131 days, September 3030 days, October 3131 days, November 3030 days, December 3131 days. In leap years, February has 2929 days; otherwise it has 2828 days. A year is a leap year if it is a multiple of 400400, or if it is a multiple of 44 but not a multiple of 100100.
  2. October 5, 1582 (inclusive) to October 14, 1582 (inclusive): these dates do not exist. These dates were removed, so the day after October 4 is October 15.
  3. On and before October 4, 1582 (inclusive): use the Julian calendar. The days in each month are the same as in the Gregorian calendar, but a year is a leap year as long as it is a multiple of 44.
  4. Although the Julian calendar was only introduced in 45 BC, and there were some adjustments in its early period, today people are used to extending the final Julian calendar rules backward for all dates before October 4, 1582. Note that there is no year 0, i.e., the year after 1 BC is AD 1. Therefore, years such as 1 BC, 5 BC, 9 BC, 13 BC, ... should be treated as leap years.

Input Format

The first line contains an integer QQ, the number of queries.
Then follow QQ lines, each containing a non-negative integer rir_i, representing a Julian day.

Output Format

For each Julian day rir_i, output one line with a date string sis_i. There are QQ lines in total. The format of sis_i is as follows:

  1. If the year is AD, output Day Month Year. The day (Day), month (Month), and year (Year) have no leading zeros, and are separated by one space. For example, for 12:00 noon on November 7, 2020 AD, output 7 11 2020.
  2. If the year is BC, output Day Month Year BC. The year (Year) should be the numeric value of that year; the rest is the same as the AD format. For example, for 12:00 noon on February 1, 841 BC, output 1 2 841 BC.
3
10
100
1000
11 1 4713 BC
10 4 4713 BC
27 9 4711 BC
3
2000000
3000000
4000000
14 9 763
15 8 3501
12 7 6239
见附件中的 julian/julian3.in
见附件中的 julian/julian3.ans

Hint

Constraints

Test Point ID Q=Q = rir_i \le
11 10001000 365365
22 10410^4
33 10510^5
44 1000010000 3×1053\times 10^5
55 2.5×1062.5\times 10^6
66 10510^5
77 5×1065\times 10^6
88 10710^7
99 10910^9
1010 the answer year does not exceed 10910^9

Translated by ChatGPT 5