結果

問題 No.87 Advent Calendar Problem
ユーザー 沙耶花沙耶花
提出日時 2021-10-22 20:32:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 4,529 ms
コンパイル使用メモリ 262,652 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-24 10:20:47
合計ジャッジ時間 6,968 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
4,368 KB
testcase_01 AC 90 ms
4,368 KB
testcase_02 AC 19 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 50 ms
4,368 KB
testcase_07 AC 68 ms
4,368 KB
testcase_08 AC 39 ms
4,368 KB
testcase_09 AC 57 ms
4,368 KB
testcase_10 AC 70 ms
4,368 KB
testcase_11 AC 93 ms
4,368 KB
testcase_12 AC 110 ms
4,368 KB
testcase_13 AC 82 ms
4,368 KB
testcase_14 AC 126 ms
4,368 KB
testcase_15 AC 53 ms
4,368 KB
testcase_16 AC 3 ms
4,368 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 73 ms
4,368 KB
testcase_21 AC 62 ms
4,368 KB
testcase_22 AC 46 ms
4,368 KB
testcase_23 AC 34 ms
4,368 KB
testcase_24 AC 44 ms
4,368 KB
testcase_25 AC 15 ms
4,368 KB
testcase_26 AC 127 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 100000000000000000


int main(){
	
	long long N;
	cin>>N;
	
	vector<int> start(7,0);
	int sum = 0;
	rep(i,7){
		int cur = i;
		rep(j,400){
			cur++;
			if(j%400==0)cur++;
			else if(j%100!=0&&j%4==0)cur++;
			cur %= 7;
			if(cur==0)start[i] ++;
		}
		if(i==0)sum = cur;
	}
	
	long long ans = 0LL;
	int cur = 0;
	for(long long i=2015;i<=N;i++){
		if(i%400==0 && i+399<=N){
			ans += start[cur];
			cur += sum;
			cur %= 7;
			i+=399;
		}
		else{
			cur ++;
			if(i%400==0)cur++;
			else if(i%100!=0&&i%4==0)cur++;
			cur%=7;
			if(cur==0)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0