题解:P13554 【MX-X15-T1】奶龙龙

首先不促销,要买 aa 个,每个 xx 元,花费是 xaxa

然后是促销,要买 yy 个才能促销,每个 zz 元,花费 yzyz

我们写好代码。

1
2
3
4
5
6
7
8
9
#include<bits/stdc++.h>
using namespace std;
int x,y,z,a;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>x>>y>>z>>a;
cout<<min(a*x,y*z);
return 0;
}

发现 WA 了。

因为 yy 可能比 aa 小,但题目说必须要买 aa 个,所以 yy 要和 aa 取最大值。

1
2
3
4
5
6
7
8
9
10
#include<bits/stdc++.h>
using namespace std;
int x,y,z,a;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>x>>y>>z>>a;
y=max(y,a);
cout<<min(a*x,y*z);
return 0;
}

题解:P13554 【MX-X15-T1】奶龙龙
http://zhoujunchen666.github.io/2025/08/07/题解:P13554-【MX-X15-T1】奶龙龙/
作者
zhoujunchen
发布于
2025年8月7日
许可协议