結果

問題 No.87 Advent Calendar Problem
ユーザー peroon
提出日時 2019-04-24 15:00:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,467 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 166,672 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 23:15:17
合計ジャッジ時間 2,598 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
bool is_ururu(ll y){
if(y%400==0) return true;
if(y%100==0) return false;
if(y%4==0) return true;
return false;
}
// startend
ll calc_count(ll start, ll end){
ll zure = 0;
ll count = 0;
FOR(y, start, end+1){
if(is_ururu(y)){
zure+=2;
}else{
zure+=1;
}
zure %= 7;
if(zure==0){
count++;
}
}
return count;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// input
ll N;
cin >> N;
//
if(N<5000){
ll count = calc_count(2015, N);
p(count);
return 0;
}
ll num_per_400_years = 0;
ll zure = 0;
FOR(i, 2015, 2015+400){
if(is_ururu(i)){
zure += 2;
}else{
zure += 1;
}
zure %= 7;
if(zure==0){
num_per_400_years++;
}
}
// 2400
ll diff = N - 2014;
ll loop = diff / 400;
ll count2 = loop * num_per_400_years;
ll count1 = calc_count(2015, N-400*loop);
p(count1+count2);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0