結果

問題 No.87 Advent Calendar Problem
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-08 19:30:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 890 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 7,980 KB
最終ジャッジ日時 2023-09-25 07:12:59
合計ジャッジ時間 1,968 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,864 KB
testcase_01 AC 17 ms
7,844 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 15 ms
7,740 KB
testcase_04 AC 15 ms
7,824 KB
testcase_05 AC 16 ms
7,924 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 16 ms
7,764 KB
testcase_08 AC 16 ms
7,792 KB
testcase_09 AC 16 ms
7,884 KB
testcase_10 AC 16 ms
7,848 KB
testcase_11 AC 16 ms
7,828 KB
testcase_12 AC 15 ms
7,844 KB
testcase_13 AC 16 ms
7,764 KB
testcase_14 AC 15 ms
7,760 KB
testcase_15 AC 16 ms
7,892 KB
testcase_16 AC 16 ms
7,980 KB
testcase_17 AC 16 ms
7,876 KB
testcase_18 AC 17 ms
7,884 KB
testcase_19 AC 16 ms
7,796 KB
testcase_20 AC 17 ms
7,788 KB
testcase_21 AC 16 ms
7,948 KB
testcase_22 AC 16 ms
7,876 KB
testcase_23 AC 15 ms
7,880 KB
testcase_24 AC 15 ms
7,764 KB
testcase_25 AC 16 ms
7,876 KB
testcase_26 AC 16 ms
7,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(year):
    q, r = divmod(year-2000, 400)
    return q * count400(399) + count400(r) - 3

def count400(year):
    '''
    水曜日を0
    木曜日を1
    金曜日を2
    ...
    火曜日を6
    であらわすとする。
    400年単位で切りが良いので、2000年から数え始めることにする。
    2014 0
    2013 6
    2012 5
    2011 3
    2010 2
    2009 1
    2008 0
    2007 5
    2006 4
    2005 3
    2004 2
    2003 0
    2002 6
    2001 5
    2000 4
    '''
    weekday = 4
    count = 0
    for n in range(1, year + 1):
        weekday += 1 + is_leap_year(n)
        weekday %= 7
        if weekday == 0:
            count += 1
    return count

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

year = int(input())
print(solve(year))
0