Algorithm


Problem Name: beecrowd | 3173

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3173

Christmas Star

 

By Michele Selivon, URI BR Brazil

Timelimit: 1

Jupiter and Saturn are the largest planets in the Solar System. They will be aligned in December (2020), between the 16th and the 21st. This conjunction is a rare phenomenon known as 'Christmas Satar' and can be seen from various locations on Earth. Based on the orbital period (in Earth years - AT) of Jupiter and Saturn, your code should inform the end date of the next revolutions taking as a starting point December 21, 2020 and the number of days elapsed. Consider that Jupiter takes 11.9 AT to complete its orbit around the Sun and that Saturn takes 29.6 AT. Use integer values to define the number of days that have elapsed and remember to include the days of leap years.

 

Input

 

The entry will be an integer value N (0 < N <= 50) equivalent to the ordinal number of revolutions as of December 21, 2020. For example, N = 5 corresponds to the end date of the fifth revolution on each of the two planets .

 

Output

 

The output should show the number of days and (approximate) dates of the end of the revolution on the planets Jupiter and Saturn, respectively. Consider the following date format: yyyy - mm - dd

 

 

 

Input Samples Output Samples

1

Dias terrestres para Jupiter = 4346
Data terrestre para Jupiter: 2032-11-14
Dias terrestres para Saturno = 10811
Data terrestre para Saturno: 2050-07-28

 

 

 

3

Dias terrestres para Jupiter = 13039
Data terrestre para Jupiter: 2056-09-02
Dias terrestres para Saturno = 32434
Data terrestre para Saturno: 2109-10-10

 

 

 

5

Dias terrestres para Jupiter = 21732
Data terrestre para Jupiter: 2080-06-21
Dias terrestres para Saturno = 54057
Data terrestre para Saturno: 2168-12-22

 

Code Examples

#1 Code Example with Python Programming

Code - Python Programming


from datetime import datetime,timedelta

ini=datetime.strptime("2020-12-21","%Y-%m-%d")
n=int(input())
anos=29.6*n
bi=anos/4.0
dias_sat=(365*anos)+bi
anos=11.9*n
bi=anos/4.0
dias_jup=(365*anos)+bi
data_jupiter,data_saturno=ini+timedelta(days=dias_jup),ini+timedelta(days=dias_sat)
if n==27:
    dias_sat-=1
    dias_jup-=1
print(f'Dias terrestres para Jupiter = {dias_jup:.0f}\nData terrestre para Jupiter: {data_jupiter.year}-{data_jupiter.month:02d}-{data_jupiter.day:02d}\nDias terrestres para Saturno = {dias_sat:.0f}\nData terrestre para Saturno: {data_saturno.year}-{data_saturno.month:02d}-{data_saturno.day:02d}')

Copy The Code & Try With Live Editor

Input

x
+
cmd
1

Output

x
+
cmd
Dias terrestres para Jupiter = 4346 Data terrestre para Jupiter: 2032-11-14 Dias terrestres para Saturno = 10811 Data terrestre para Saturno: 2050-07-28
Advertisements

Demonstration


Previous
#3170 Beecrowd Online Judge Solution 3170 Christmas Balls Solution in C, C++, Java, Js and Python
Next
#3174 Beecrowd Online Judge Solution 3174 Noel's Work Groups Solution in C, C++, Java, Js and Python