結果

問題 No.87 Advent Calendar Problem
ユーザー erbowl
提出日時 2025-01-27 22:03:11
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,377 bytes
コンパイル時間 4,151 ms
コンパイル使用メモリ 315,628 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-27 22:03:16
合計ジャッジ時間 5,375 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;

#include <bits/stdc++.h>
using namespace std;
// #define int long long

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// std::cout << *s.find_by_order(1) << std::endl; // 2

vector<string> split(string str, char del) {
   int first = 0;
   int last = str.find_first_of(del);
   vector<string> result;
 
   while (first < str.size()) {
     result.push_back(str.substr(first, last - first));
     first = last + 1;
     last = str.find_first_of(del, first);
     if (last == string::npos) last = str.size();
   }
   return result;
 }

signed main(){
    // これがないと落ちることがある
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin >> n;
    n-=2015;

    ll kai = n/400;
    ll am = n%400;
    ll now = 0;
    ll cnt = 0;
    ll amm = 0;
    for (ll i = 0; i < 400; i++){
        if((2015+i)%400==0){
            now += 366;
        }else if((2015+i)%100==0){
            now += 365;
        }else if((2015+i)%4==0){
            now += 366;
        }else{
            now += 365;
        }
        if(now%7==0){
            cnt++;
            if(i<=am){
                amm++;
            }
        }
    }

    cout << kai*cnt+amm << endl;

}
0