結果

問題 No.740 幻の木
ユーザー Hydrogen332
提出日時 2024-09-28 01:00:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 3,044 ms
コンパイル使用メモリ 192,228 KB
最終ジャッジ日時 2025-02-24 13:49:47
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; i++)

int main() {
    cin.tie(nullptr);
    
    int N, M, P, Q;
    cin >> N >> M >> P >> Q;
    
    int y = M * 12 + Q * M;
    int ans = (N / y) * 12;
    N %= y;
    
    rep(i, 1, 13) {
        if (P <= i && i <= P + Q - 1) N -= 2 * M;
        else N -= M;
        
        if (N <= 0) {
            cout << i + ans << '\n';
            return 0;
        }
    }
}
0