結果

問題 No.87 Advent Calendar Problem
コンテスト
ユーザー むらため
提出日時 2019-02-03 23:03:09
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 818 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,973 ms
コンパイル使用メモリ 68,216 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-22 11:05:54
合計ジャッジ時間 2,778 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 23 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #
raw source code

import sequtils

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': return
    result = 10 * result + k.ord - '0'.ord

# うるう年以外 : +1 | うるう年 : +2
let n = scan()
proc solve(n:int,start:int=2014,x:int = 0):int =
  var x = x
  for i in (start+1)..n:
    if i mod 4 == 0 :
      if i mod 100 == 0 :
        if i mod 400 == 0 : x += 2
        else: x += 1
      else: x += 2
    else: x += 1
    if x == 7 : result += 1
    x = x mod 7

let start = 2800
if n <= start: quit $(solve(n)),0
let ans = 111 + 57 * (n div 400 - 7)
echo ans + solve(n,(n div 400) * 400,4)
# var pre = 0
# for i in countup(2400,100_000,400):
#   var next = solve(i)
#   echo i,":",next,": +",next - pre
#   pre = next
0