結果

問題 No.740 幻の木
ユーザー ut0sut0s
提出日時 2019-09-15 07:56:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 164,368 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 04:00:54
合計ジャッジ時間 2,051 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
  @file 740.cpp
  @title  No.740 幻の木 - yukicoder
  @url https://yukicoder.me/problems/no/740
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  LL N, M, P, Q;
  cin >> N >> M >> P >> Q;

  LL max_month = (N + M + 1) / M;
  for (LL i = 1; i <= max_month; i++) {
    LL month = (i % 12) == 0 ? 12 : i % 12;
    if (P <= month && month <= P + Q - 1) {
      N -= 2 * M;
    } else {
      N -= M;
    }

    if (N <= 0) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}
0