3
2023-07-30 20:30:35
发布于:广东
#include<bits/stdc++.h>
#include<queue>
using namespaceespace std;
int x,y,m;
int bfs(int m) {
int ma=-99;
queue<int> q;
q.push(0);
while(q.size()) {
int r=q.front();
q.pop();
int nr;
nr=r+x;
if(nr<=m) {
ma=max(ma,nr);
q.push(nr);
}
nr=r+y;
if(nr<m) {
ma=max(ma,nr);
q.push(nr);
}
}
return ma;
}
int main() {
freopen("pails.in","r",stdin);
freopen("pails.out","w",stdout);
cin>>x>>y>>m;
cout<<bfs(m);
fclose(stdin);
fclose(stdout);
return 0;
}
这里空空如也
有帮助,赞一个