LoginSignup
0
0

More than 3 years have passed since last update.

Pythonで毎日AtCoder #2

Last updated at Posted at 2020-03-11

はじめに

前回
二日目です。

#2

問題

考えたこと
問題の公式どおりに実装しました。
注意する点は、1、2月は前年の13、14月として計算する点です。
また、ガウス記号はPythonでmath.floor関数を使って実装できます。
(追記)math.floor使わなくても、//でできるので変更しました。


#import math #floor関数を使う
y = int(input())
m = int(input())
d = int(input())

seed = 735369
def cal(y,m,d):
    return 365 * y + y//4 - y//100 + y//400 + 306*(m+1)//10 + d - 429
    #return 365 * y + math.floor(y/4) - math.floor(y/100) + math.floor(y/400) + math.floor(306*(m+1)/10) + d - 429
if m <= 2:
    y -= 1
    m += 12
    ans = cal(y,m,d)
    print(seed - ans)
else:
    ans = cal(y,m,d)
    print(seed - ans)

まとめ

昔の問題は今の問題と傾向が違うので、解くのが楽しい。では次回へ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0