結果

問題 No.894 二種類のバス
ユーザー ponponpainful
提出日時 2019-09-27 21:39:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 1,448 ms
コンパイル使用メモリ 166,524 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 21:01:08
合計ジャッジ時間 2,168 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

template<typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int main() {
  long long t, a, b; cin>>t>>a>>b;
  long long ans = 0;
  long long l = lcm(a, b);
  ans += (t-1)/a + (t-1)/b + 1;
  ans -= (t-1)/l;
  print(ans);

  return 0;
}
0