結果
| 問題 |
No.894 二種類のバス
|
| コンテスト | |
| ユーザー |
n0ma_ru
|
| 提出日時 | 2024-04-10 13:13:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 838 bytes |
| コンパイル時間 | 2,012 ms |
| コンパイル使用メモリ | 192,388 KB |
| 最終ジャッジ日時 | 2025-02-20 23:41:06 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) v.begin(),v.end()
#define dbg(x) cerr << #x << ": " << (x) << endl;
template<class F, class S>
ostream& operator<<(ostream& os, pair<F,S>& p) {
os << '(' << p.first << ',' << p.second << ')';
return os;
}
template<class Iter>
void print(Iter beg, Iter end) {
for (Iter itr = beg; itr != end; ++itr) {
cerr << *itr << ' ';
}
cerr << '\n';
}
ll t,a,b;
ll lcm(ll x, ll y) {
ll g = gcd(x, y);
if (x / g >= (ll(1e18) + 1) / y) {
return ll(1e18) + 1;
} else {
return x / gcd(x,y) * y;
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> t >> a >> b;
--t;
ll ans = t / a + 1;
ans += t / b + 1;
ans -= t / lcm(a,b) + 1;
cout << ans << '\n';
}
n0ma_ru