Source Code
#include <iostream>
#include <cmath>
using namespace std;


int main()
{
 // freopen("input.txt", "r", stdin);
 // freopen ("output.txt", "w", stdout);

  int p, x, y, t, sum=0;;
  cin >> p >> x >> y;
  t = p;
  int i = min(x,y);
  t--;
  for (;t>0;i++){
    if (i%y == 0 || i == y) { t--; if (t == 0) break;}
    if (i%x == 0 || i == x) { t--;}
  }
  cout << i;





  return 0;

}
Copy
Hurry up Mutasem02
GNU G++17
1099 ms
520 KB
Time Limit Exceeded