結果

問題 No.87 Advent Calendar Problem
コンテスト
ユーザー IL_msta
提出日時 2015-07-07 09:41:14
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,001 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 781 ms
コンパイル使用メモリ 103,540 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-29 17:18:42
合計ジャッジ時間 1,624 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:54:12: warning: 'ppp' may be used uninitialized [-Wmaybe-uninitialized]
   54 |         LL ans = (N-2014)/(400*7) * same + ppp;
      |            ^~~
main.cpp:38:12: note: 'ppp' was declared here
   38 |         LL ppp;
      |            ^~~

ソースコード

diff #
raw source code

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//

	LL day0 = 2014/4 - 2014/100 + 2014/400;
	LL N;
	cin>>N;
	LL plus = 0;
	LL pp = (N-2014)%(400*7);
	LL ppp;
	//plus = (N/4 - N/100 + N/400 - day0) + N-2014;
	LL same=0;
	for(LL i = 2014; i < 2014+400*7; ++i){
		if(plus%7==0){
			++same;
		}
		if(2014+pp == i){
			ppp = same;
		}
		//
		++plus;
		if((i+1)%4==0 && ((i+1)%400==0 || (i+1)%100 != 0) ){
			++plus;
		}
	}
	LL ans = (N-2014)/(400*7) * same + ppp;
	P(ans-1);
    return 0;
}
0