結果

問題 No.740 幻の木
ユーザー lam6er
提出日時 2025-03-31 17:39:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 53,228 KB
最終ジャッジ日時 2025-03-31 17:41:07
合計ジャッジ時間 1,025 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

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

N, M, P, Q = map(int, input().split())
month_shed = []
for month in range(1, 13):
end_month = P + Q - 1
if P <= month <= end_month:
month_shed.append(2 * M)
else:
month_shed.append(M)
sum_cycle = sum(month_shed)
current_leaves = N
count = 0
current_month = 1 # 1-based month (1-12)
if sum_cycle > 0 and current_leaves >= sum_cycle:
cycles = current_leaves // sum_cycle
current_leaves -= cycles * sum_cycle
count += cycles * 12
while current_leaves > 0:
a = month_shed[current_month - 1]
if current_leaves <= a:
count += 1
break
current_leaves -= a
count += 1
current_month = (current_month % 12) + 1
print(count)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0