結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
|
提出日時 | 2018-09-20 16:31:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 521 bytes |
コンパイル時間 | 442 ms |
コンパイル使用メモリ | 65,456 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 08:35:11 |
合計ジャッジ時間 | 1,303 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<iostream>using namespace std;typedef long long ll;bool isLeap(ll y){return y%4 == 0 && (y%100 != 0 || y%400 == 0);}int main(){ll n;cin >> n;ll unit = 0, pass = 0;for(int i = 2015; i < 2415; i++){pass++;if(isLeap(i)) pass++;if(pass % 7 == 0) unit++;}ll block = (n-2014) / 400;ll ans = unit * block;pass = (pass * block) % 7;for(ll i = 2015 + block * 400; i <= n; i++){pass++;if(isLeap(i)) pass++;if(pass % 7 == 0) ans++;}cout << ans << endl;return 0;}