結果

問題 No.740 幻の木
ユーザー chacoder1chacoder1
提出日時 2020-12-29 09:44:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 194,140 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 09:46:26
合計ジャッジ時間 3,132 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
  int N,M,P,Q;
  cin>>N>>M>>P>>Q;
  //YD 1年に落とす葉の数
  int YD=0;
  YD=M*12+Q*M;
  //cnt 経過月数
  int cnt=0;
  cnt+=(N/YD)*12;
  //DD 年単位で葉を落とした後の余った葉の数
  int DD=0;
  DD=N-YD*(N/YD);
  //剰余月数
  int MM=0;
  while(DD>0){
    cnt++;
    MM++;
    //cout<<cnt<<" "<<DD<<endl;
    if(MM>=P && MM<=P+Q-1){
      DD-=(2*M);
    }
    else{
      DD-=M;
    }
    if(MM==12){
      MM=0;
    }
  }
  cout<<cnt<<endl; 
  return 0;
}

  

0