結果
| 問題 |
No.894 二種類のバス
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-27 22:29:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 1,640 ms |
| コンパイル使用メモリ | 167,428 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 20:35:22 |
| 合計ジャッジ時間 | 2,432 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)
inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
template<typename T>
T gcd(T a, T b) {
while (a) {
b %= a;
swap(a, b);
}
return b;
}
template<typename T>
T lcm(T a, T b) {
T ret = a / gcd(a, b) * b;
if (b <= numeric_limits<T>::max() / (a / gcd(a, b))) return ret;
else return numeric_limits<T>::max();
}
int main() {
long long t, a, b; cin>>t>>a>>b;
long long ans = 0;
long long l = lcm(a, b);
ans += (t-1)/a + (t-1)/b + 1;
ans -= (t-1)/l;
print(ans);
return 0;
}