結果
問題 |
No.894 二種類のバス
|
ユーザー |
|
提出日時 | 2019-09-27 21:35:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,189 bytes |
コンパイル時間 | 812 ms |
コンパイル使用メモリ | 89,612 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 20:54:39 |
合計ジャッジ時間 | 1,476 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 1 |
ソースコード
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <stack> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <set> #include <cstdlib> #include <bitset> #include <tuple> #include <assert.h> #include <deque> #include <bitset> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 510000; const long long INF = 1LL << 60; const long long MOD = 1000000007LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll gcd(ll x, ll y) { ll r; if (x < y) { swap(x, y); } while (y > 0) { r = x % y; x = y; y = r; } return x; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll T, A, B; cin >> T >> A >> B; ll lc = lcm(A, B); ll cnt = 0; if (T % A == 0) { cnt += T / A; } else { cnt += T / A + 1; } if (T %B == 0) { cnt += T / B; } else { cnt += T / B + 1; } if (T % lc == 0) { cnt -= T / lc; } else { cnt -= T / lc + 1; } if (cnt <= 0) { assert(false); } cout << cnt << endl; return 0; }