結果
問題 |
No.894 二種類のバス
|
ユーザー |
![]() |
提出日時 | 2019-09-27 21:35:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 74,388 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 20:54:57 |
合計ジャッジ時間 | 1,235 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; ll gcd(ll n, ll m) { if (n < m) swap(n, m); while (m != 0) { ll r = n % m; n = m; m = r; } return n; } int main() { ll t, a, b; cin >> t >> a >> b; ll g = gcd(a, b); ll c = a / g * b; if (a / g * (double)b >= t * 2) c = t; auto f = [t](ll a) { return (t + a - 1) / a; }; cout << f(a) + f(b) - f(c) << endl; return 0; }