結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
|
提出日時 | 2016-08-29 17:51:19 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 679 ms |
コンパイル使用メモリ | 113,840 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 03:49:19 |
合計ジャッジ時間 | 1,438 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import std.algorithm, std.array, std.container, std.range;import std.string, std.conv, std.bigint, std.math, std.random;import std.stdio, std.typecons;void main(){auto n = readln.chomp.to!long;auto ri = iota(2800).map!(y => calc(y));auto c = ri.count!(r => r == ri[2014]);auto r = (n - 2015) / 2800 * c;auto m = (n - 2015) % 2800;if (m + 2015 < 2800) {r += ri[2015..m + 2015 + 1].count!(r => r == ri[2014]);} else {r += ri[2015..$].count!(r => r == ri[2014]);r += ri[0..m + 2015 - 2800 + 1].count!(r => r == ri[2014]);}writeln(r);}long calc(long y){return (y + y / 4 - y / 100 + y / 400) % 7;}