AcWing 1842. 牛奶桶
原题链接
简单
作者:
qxh
,
2022-04-21 20:43:13
,
所有人可见
,
阅读 123
#include <iostream>
using namespace std;
const int N = 100010;
int ans[N];
int k, i, j;
int main()
{
int res = 0;
int x, y, m;
scanf("%d%d%d",&x, &y, &m);
for(i = 0; i <= m / y; i ++ )
{
for(j = 0; j <= m / x; j ++ )
{
if(i * y + j * x <= m) ans[k ++ ] = i * y + j * x;
}
j = 1;
}
//for(int i = 0; i < k; i ++ ) cout << ans[i] << ' ';
//puts("");
for(int i = 0; i < k; i ++ )
{
res = max(res, ans[i]);
}
printf("%d\n", res);
return 0;
}