結果

問題 No.87 Advent Calendar Problem
ユーザー ty70
提出日時 2015-06-05 03:26:11
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,769 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 92,060 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 14:09:02
合計ジャッジ時間 1,299 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

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

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int cycle[] = { 11, 6, 5, 6, 11, 6, 5, 6, 11, 6, 5, 6, 6, 6, 11, 6, 5, 6, 11, 6, 5, 6, 11, 6, 5, 6, 6, 6, 11, 6, 5, 6, 11, 6, 5, 6, 11, 6, 5, 6,
    12, 11, 6, 5, 6, 11, 6, 5, 6, 11, 6, 5, 6, 11, 6, 5, 6 };
int main()
{
ios_base::sync_with_stdio(0);
int cn = sizeof (cycle )/sizeof(cycle[0] );
vector<ll> sum (cn, 0LL );
for (int i = 0; i < cn; i++ ){
sum[i] = (i != 0 ? sum[i-1] : 0 ) + (ll)cycle[i];
} // end for
// int T; cin >> T;
// while (T-- ){
ll N; cin >> N;
int res = 0;
if (N >= 2014LL ){
ll n = N - 2014LL;
ll m = n/400LL;
res += (ll)cn*m;
n %= 400LL;
vector<ll>::iterator it = lower_bound (ALL (sum ), n );
vector<ll>::iterator jt = upper_bound (ALL (sum ), n );
ll curr = 0LL;
if (it == jt )
curr = (ll)(jt - sum.begin() );
else
curr = (ll)(it - sum.begin() ) + 1LL;
res += curr;
} // end if
// cerr << N << ' ';
cout << res << endl;
// } // end while
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0