結果

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

ソースコード

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(2014, 2414)
else:
    total = loop_count(2014, 2414)
    total *= (N-2014) // 400
    total += loop_count(2014 + (N-2014)//400*400 + 1, N)

print(total)
0