只要找出一个数可以包含符合要求的两个集合就好了,昨天各种脑残,不说也罢。
#include<iostream>
using namespace std;
int c1, c2, x, y, ans;
int main()
{
cin >> c1 >> c2 >> x >> y;
ans = c1 + c2;
while (ans - ans / x < c1)
ans += c1 - (ans - ans / x);
while (ans - ans / y < c2)
ans += c2 - (ans - ans / y);
while (ans - ans / (x * y) < c1 + c2)
ans += (c1 + c2) - (ans - ans / (x * y));
cout << ans << endl;
return 0;
}
本文介绍了一种算法,用于找到能同时满足两个特定条件的最小整数。该算法通过循环迭代逐步逼近目标值,最终输出满足条件的整数。
617

被折叠的 条评论
为什么被折叠?



