結果

問題 No.87 Advent Calendar Problem
コンテスト
ユーザー 👑 kmjp
提出日時 2014-12-07 00:08:52
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,030 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 873 ms
コンパイル使用メモリ 176,784 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-25 13:52:30
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:26:21: warning: 'x' is used uninitialized [-Wuninitialized]
   26 |                 if(x%400 || (x%100!=0 &&x%4==0)) y++;
      |                    ~^~~~
main.cpp:17:23: note: 'x' was declared here
   17 |         int i,j,k,l,r,x,y; string s;
      |                       ^

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	
	int i2800=0;
	y=0;
	FOR(i,2800) {
		y++;
		if(x%400 || (x%100!=0 &&x%4==0)) y++;
		if(y%7==0) i2800++;
	}
	
	
	ll dif=N-2014;
	ll ret=dif/2800*i2800;
	N -= dif/2800*2800;
	y=1;
	for(x=2015;x<=N;x++) {
		if(y%7==0) ret++;
		y++;
		if(x%400 || (x%100!=0 &&x%4==0)) y++;
	}
	cout<<ret<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0