标签:algorithm codeforces 算法 acm
#include <cstdio> #include <algorithm> #include <cstring> #include <iostream> using namespace std; int main() { long long cnt1, cnt2, x, y; cin >> cnt1 >> cnt2 >> x >> y; long long l = 0, r = 10000000000, m; while (r > l + 1) { m = (l + r) / 2; if (m - m / x >= cnt1 && m - m / y - max(0LL, cnt1 - m / y + m / (x * y)) >= cnt2) r = m; else l = m; } cout << r << endl; return 0; }
Codeforces Round #275 (Div. 2) B
标签:algorithm codeforces 算法 acm
原文地址:http://blog.csdn.net/notdeep__acm/article/details/40445731