#41723: C++解答不會再看


ken.mhhsu@gmail.com (Ken Min-Hao Hsu)

學校 : 不指定學校
編號 : 256975
來源 : [118.166.202.166]
最後登入時間 :
2024-06-18 20:24:30
e969. 大吃大喝 (Big eater) -- TOI練習賽201903新手組第3題 | From: [36.229.30.25] | 發表日期 : 2024-08-20 14:34

#include <bits/stdc++.h>
using namespace std;
int main() {
  int money, minu, k;
  cin >> money >> minu >> k;
  int totim = (-1) * minu;
  int whether = 0;
  while (money > 0) {
    if (k == 1) {
      if (money > 55) {
        money -= 55;
        totim += minu;
        whether = 1;
        cout << totim << ": "
             << "Wayne drinks a Corn soup, and now he has " << money;
        k = 0;
        if (money == 1) {
          cout << " dollar." << endl;
        } else {
          cout << " dollars." << endl;
        }
        continue;
      }
      if (money == 55) {
        money -= 55;
        totim += minu;
        whether = 1;
        cout << totim << ": "
             << "Wayne drinks a Corn soup, and now he doesn't have money.";
      }
      if (money < 55) {
        break;
      }
      k = 0;
    }
    if (k == 0) {
      if (money > 32) {
        money -= 32;
        totim += minu;
        whether = 1;
        cout << totim << ": "
             << "Wayne eats an Apple pie, and now he has " << money;
        if (money == 1) {
          cout << " dollar." << endl;
        } else {
          cout << " dollars." << endl;
        }
        k = 1;
        continue;
      }
      if (money == 32) {
        money -= 32;
        totim += minu;
        whether = 1;
        cout << totim << ": "
             << "Wayne eats an Apple pie, and now he doesn't have money.";
      }
      if (money < 32) {
        break;
      }
    }
  }
  if (whether == 0) {
    cout << "Wayne can't eat and drink.";
  }
}

 
ZeroJudge Forum