結果

問題 No.87 Advent Calendar Problem
ユーザー nbisco
提出日時 2017-01-15 23:26:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-12-21 14:54:08
合計ジャッジ時間 2,131 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_leap(n):
    if n % 400 == 0:
        return True
    if n % 100 == 0:
        return False
    if n % 4 == 0:
        return True
    return False

def loop_count(start, end):
    total = 0
    diff = 0
    for i in range(start, end+1):
        if is_leap(i):
            diff += 2
        else:
            diff += 1
        if diff % 7 == 0:
            total += 1
            diff = 0
    return total


N = int(input())
total = 0
if N <= 2414:
    total = loop_count(2015, N)
else:
    total = loop_count(2015, 2414)
    total *= (N-2014) // 400
    total += loop_count(2014 + (N-2014)//400*400 + 1, N)

print(total)
0