結果

問題 No.894 二種類のバス
ユーザー noisy_noiminnoisy_noimin
提出日時 2019-09-27 21:34:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 764 bytes
コンパイル時間 7,253 ms
コンパイル使用メモリ 395,084 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 20:54:12
合計ジャッジ時間 7,567 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

mp::cpp_int gcd(mp::cpp_int a, mp::cpp_int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

mp::cpp_int lcm(mp::cpp_int a, mp::cpp_int b)  {
    return a / gcd(a, b) * b;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    mp::cpp_int t, a, b;
    cin >> t >> a >> b;
    mp::cpp_int l = lcm(a, b);

    mp::cpp_int ans = ((t-1)/a+1) + ((t-1)/b+1) - ((t-1)/l+1);
    cout << ans << endl;
}
0