結果
問題 | No.894 二種類のバス |
ユーザー |
|
提出日時 | 2021-12-18 00:27:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 193,240 KB |
最終ジャッジ日時 | 2025-01-27 02:46:07 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair<int, int> #define LP pair<ll, ll> const ll INF = 1e18; int main() { ll t, a, b; cin >> t >> a >> b; ll ans = (t-1)/a+(t-1)/b+2; ll g = gcd(a,b); if (a/g < INF/b) { ll l = a/g*b; ans -= (t-1)/l+1; } else { ans--; } cout << ans << endl; return 0; }