結果

問題 No.894 二種類のバス
ユーザー 0w1
提出日時 2019-09-28 03:07:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 357 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 192,116 KB
最終ジャッジ日時 2025-01-07 19:43:16
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t T, A, B;
  cin >> T >> A >> B;

  int64_t g = __gcd(A, B);
  if (1.0 * A * B / g < T) {
    int64_t x = A / g * B;
    cout << (1 + (T - 1) / A) + (1 + (T - 1) / B) - (1 + (T - 1) / x) << endl;
  } else {
    cout << (1 + (T - 1) / A) + (1 + (T - 1) / B) - 1 << endl;
  }

  return 0;
}
0