#include <stdio.h>
int main() {
int N, X, Y;
printf("請輸入 N、X、Y (0 < Y): "); scanf("%d %d %d", &N
, &X
, &Y
);
int temperature = 20; // 初始溫度為20攝氏度
// 如果N是奇數,先把N減1,再“先加熱後冷卻”
if (N % 2 == 1) {
N -= 1;
temperature += X; // 先加熱
}
// 使用循環計算最高溫度
for (int i = 0; i < N / 2; i++) {
// 先加熱
temperature += X;
// 再冷卻
temperature -= Y;
if (temperature < 20) {
// 如果溫度低於室溫,設為室溫
temperature = 20;
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBOLCBYLCBZOwogICAgcHJpbnRmKCLoq4vovLjlhaUgTuOAgVjjgIFZICgwIDwgWSk6ICIpOwogICAgc2NhbmYoIiVkICVkICVkIiwgJk4sICZYLCAmWSk7CgogICAgaW50IHRlbXBlcmF0dXJlID0gMjA7ICAvLyDliJ3lp4vmuqvluqbngroyMOaUneawj+W6pgoKICAgIC8vIOWmguaenE7mmK/lpYfmlbjvvIzlhYjmiopO5ribMe+8jOWGjeKAnOWFiOWKoOeGseW+jOWGt+WNu+KAnQogICAgaWYgKE4gJSAyID09IDEpIHsKICAgICAgICBOIC09IDE7CiAgICAgICAgdGVtcGVyYXR1cmUgKz0gWDsgLy8g5YWI5Yqg54axCiAgICB9CgogICAgLy8g5L2/55So5b6q55Kw6KiI566X5pyA6auY5rqr5bqmCiAgICBmb3IgKGludCBpID0gMDsgaSA8IE4gLyAyOyBpKyspIHsKICAgICAgICAvLyDlhYjliqDnhrEKICAgICAgICB0ZW1wZXJhdHVyZSArPSBYOwogICAgICAgIC8vIOWGjeWGt+WNuwogICAgICAgIHRlbXBlcmF0dXJlIC09IFk7CiAgICAgICAgaWYgKHRlbXBlcmF0dXJlIDwgMjApIHsKICAgICAgICAgICAgLy8g5aaC5p6c5rqr5bqm5L2O5pa85a6k5rqr77yM6Kit54K65a6k5rqrCiAgICAgICAgICAgIHRlbXBlcmF0dXJlID0gMjA7CiAgICAgICAgfQogICAgfQoKICAgIHByaW50ZigiJWRcbiIsIHRlbXBlcmF0dXJlKTsKCiAgICByZXR1cm4gMDsKfQo=