結果

問題 No.87 Advent Calendar Problem
ユーザー bluemeganebluemegane
提出日時 2021-05-10 19:26:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 1,075 bytes
コンパイル時間 4,492 ms
コンパイル使用メモリ 106,268 KB
実行使用メモリ 23,796 KB
最終ジャッジ日時 2023-10-20 03:45:26
合計ジャッジ時間 6,281 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
23,796 KB
testcase_01 AC 23 ms
23,796 KB
testcase_02 AC 24 ms
23,796 KB
testcase_03 AC 24 ms
23,796 KB
testcase_04 AC 24 ms
23,796 KB
testcase_05 AC 24 ms
23,796 KB
testcase_06 AC 23 ms
23,796 KB
testcase_07 AC 24 ms
23,796 KB
testcase_08 AC 24 ms
23,796 KB
testcase_09 AC 24 ms
23,796 KB
testcase_10 AC 24 ms
23,796 KB
testcase_11 AC 24 ms
23,796 KB
testcase_12 AC 24 ms
23,796 KB
testcase_13 AC 24 ms
23,796 KB
testcase_14 AC 23 ms
23,796 KB
testcase_15 AC 24 ms
23,796 KB
testcase_16 AC 24 ms
23,796 KB
testcase_17 AC 23 ms
23,796 KB
testcase_18 AC 23 ms
23,796 KB
testcase_19 AC 24 ms
23,796 KB
testcase_20 AC 25 ms
23,796 KB
testcase_21 AC 24 ms
23,796 KB
testcase_22 AC 24 ms
23,796 KB
testcase_23 AC 24 ms
23,796 KB
testcase_24 AC 24 ms
23,796 KB
testcase_25 AC 24 ms
23,796 KB
testcase_26 AC 24 ms
23,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var t = 0;
        for (int i = 2000; i <= 2014; i++) t += check(i);
        var t2014 = t % 7;

        var n = long.Parse(Console.ReadLine().Trim());
        if (n <= 2399) Console.WriteLine(calcDays(2015, (int)n, t2014, t2014));
        else
        {
            long ans = calcDays(2015, 2399, t2014, t2014);
            var box = calcDays(2000, 2399, t2014);
            ans += (n / 400L - 2014 / 400L - 1) * box;
            ans += calcDays((n / 400L) * 400L, n, t2014);
            Console.WriteLine(ans);
        }
    }
    static int calcDays(long from, long to, int t2014, int start = 0)
    {
        var res = 0;
        var t = start;
        for (long i = from; i <= to; i++)
        {
            t += check(i);
            t %= 7;
            if (t == t2014) res++;
        }
        return res;
    }
    static int check(long y)
    {
        if (y % 400 == 0) return 2;
        else if (y % 100 == 0) return 1;
        else if (y % 4 == 0) return 2;
        else return 1;
    }
}
0