using System; using System.Collections.Generic; public class Program { private long T, A, B; public void Solve() { var sc = new Scanner(); T = sc.NextLong(); A = sc.NextLong(); B = sc.NextLong(); long lcm = MathEx.LCM(A, B); long ans = 0; ans += (T+A-1) / A; ans += (T+B-1) / B; ans -= (T+lcm-1) / lcm; Console.WriteLine(ans); } public static void Main(string[] args) { new Program().Solve(); } } #region GCD LCM /// /// 様々な数学的関数の静的メソッドを提供します. /// public static partial class MathEx { /// /// 2 つの整数の最大公約数を求めます. /// /// 最初の値 /// 2 番目の値 /// 2 つの整数の最大公約数 /// ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます. public static int GCD(int n, int m) { return (int) GCD((long) n, m); } /// /// 2 つの整数の最大公約数を求めます. /// /// 最初の値 /// 2 番目の値 /// 2 つの整数の最大公約数 /// ユークリッドの互除法に基づき最悪計算量 O(log N) で実行されます. public static long GCD(long n, long m) { n = Math.Abs(n); m = Math.Abs(m); while (n != 0) { m %= n; if (m == 0) return n; n %= m; } return m; } /// /// 2 つの整数の最小公倍数を求めます. /// /// 最初の値 /// 2 番目の値 /// 2 つの整数の最小公倍数 /// 最悪計算量 O(log N) で実行されます. public static long LCM(long n, long m) { return (n / GCD(n, m)) * m; } } #endregion #region PrimeSieve public static partial class MathEx { /// /// ある値までに素数表を構築します. /// /// 最大の値 /// 素数のみを入れた数列が返される /// 0 から max までの素数表 /// エラトステネスの篩に基づき,最悪計算量 O(N loglog N) で実行されます. public static bool[] Sieve(int max, List primes = null) { var isPrime = new bool[max + 1]; for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true; for (int i = 2; i * i <= max; i++) if (!isPrime[i]) continue; else for (int j = i * i; j <= max; j += i) isPrime[j] = false; if (primes != null) for (int i = 0; i <= max; i++) if (isPrime[i]) primes.Add(i); return isPrime; } } #endregion class Scanner { public Scanner() { _pos = 0; _line = new string[0]; } const char Separator = ' '; private int _pos; private string[] _line; #region スペース区切りで取得 public string Next() { if (_pos >= _line.Length) { _line = Console.ReadLine().Split(Separator); _pos = 0; } return _line[_pos++]; } public int NextInt() { return int.Parse(Next()); } public long NextLong() { return long.Parse(Next()); } public double NextDouble() { return double.Parse(Next()); } #endregion #region 型変換 private int[] ToIntArray(string[] array) { var result = new int[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = int.Parse(array[i]); } return result; } private long[] ToLongArray(string[] array) { var result = new long[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = long.Parse(array[i]); } return result; } private double[] ToDoubleArray(string[] array) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) { result[i] = double.Parse(array[i]); } return result; } #endregion #region 配列取得 public string[] Array() { if (_pos >= _line.Length) _line = Console.ReadLine().Split(Separator); _pos = _line.Length; return _line; } public int[] IntArray() { return ToIntArray(Array()); } public long[] LongArray() { return ToLongArray(Array()); } public double[] DoubleArray() { return ToDoubleArray(Array()); } #endregion }