結果
問題 |
No.87 Advent Calendar Problem
|
ユーザー |
|
提出日時 | 2017-01-27 10:32:25 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 539 bytes |
コンパイル時間 | 869 ms |
コンパイル使用メモリ | 97,664 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 06:37:28 |
合計ジャッジ時間 | 1,626 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; const auto period = 2800; void main() { auto n = readln.chomp.to!long; auto wi = createTable(); auto d = (n - 2014) / period, m = (n - 2014) % period + 1; writeln(d * wi.count!"a == 0" + wi[0..m].count!"a == 0" - 1); } auto createTable() { auto wi = new int[](period); foreach (i; 1..period) { wi[i] = (wi[i - 1] + 365 + ((i + 2014).isLeap ? 1 : 0)) % 7; } return wi; } auto isLeap(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); }