結果
問題 |
No.87 Advent Calendar Problem
|
ユーザー |
|
提出日時 | 2025-06-30 05:39:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,130 bytes |
コンパイル時間 | 1,802 ms |
コンパイル使用メモリ | 195,124 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-30 05:39:20 |
合計ジャッジ時間 | 3,063 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<typename T> istream &operator>>(istream &is,vector<T> &a){ for(auto &v : a) cin >> v; return is; } template<typename T> ostream &operator<<(ostream &os,const vector<T> &a){ if(a.size() == 0) return os; cout << a.at(0); for(int i=1; i<a.size(); i++) cout << " " << a.at(i); cout << "\n"; return os; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); auto leap = [&](long long x) -> int { if(x%400 == 0) return 2; else if(x%100 == 0) return 1; else if(x%4 == 0) return 2; else return 1; }; long long N; cin >> N; long long s = 0,answer = 0; if(N <= 10000){ for(int i=2015; i<=N; i++){ s = (s+leap(i))%7; answer += s==0; } cout << answer << endl; return 0; } answer = 0,s = 0; for(int i=2015; i<4815; i++) s = (s+leap(i))%7,answer += s==0; long long left = N-4814; answer *= 1+left/2800; left %= 2800; for(int i=2015; i<left+2015; i++) s = (s+leap(i))%7,answer += s==0; cout << answer << endl; }