結果

問題 No.894 二種類のバス
ユーザー mmn15277198mmn15277198
提出日時 2021-02-19 16:08:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 73,624 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-16 05:06:27
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
using ll = long long;

const int INF = 100100100;

ll gcd(ll a , ll b){
    if(a < b)swap(a , b);
    if(a % b == 0)return b;
    else return gcd(b , a % b);
}

int main(){
    ll t , a , b;
    cin >> t >> a >> b;
    ll l = a / gcd(a , b) * b;
    ll ta = t/a;
    if(t % a == 0)ta--;
    ll tb = t/b;
    if(t % b == 0)tb--;
    ll tl = (t/l);
    if(t % l == 0)tl--;
    ll ans = ta + tb - tl + 1;
    cout << ans << endl;
    return 0;
}

0