P8822 [传智杯 #3 初赛] 课程报名 题解
思路
题目还是很水的,可以纯模拟。
由于每报名完
代码
#include <bits/stdc++.h>
using namespace std;
main(){
int n, v, m, a, ans = 0;
cin >> n >> v >> m >> a;
while(n){//还有课的情况
for(int i = 1; i <= m && n != 0; i++, n--){//注意这里一定要判断 n!=0,否则肯定 WA
ans += v;//卖课
}
v += a;//涨价
}
cout << ans;
return 0;
}