結果

問題 No.87 Advent Calendar Problem
ユーザー koba-e964
提出日時 2015-06-07 16:31:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 430 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 54,624 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 14:33:56
合計ジャッジ時間 1,060 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;

int dp[400];

int main(void){
  ll n;
  cin >> n;
  REP (i, 0, 400) {
    dp[i] = (i + i / 4 - i / 100 + i / 400) % 7;
  }
  ll c = 0;
  ll q = 0; 
  REP(i, 15, n % 400 + 401) {
    c += dp[14] == dp[i % 400];
  }
  REP(i, 0, 400) {
    q += dp[14] == dp[i];
  }
  cout << c + q * (n / 400 - 6) << endl;
}
0