結果
| 問題 |
No.894 二種類のバス
|
| コンテスト | |
| ユーザー |
tonegawa
|
| 提出日時 | 2020-08-18 19:29:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 1,636 bytes |
| コンパイル時間 | 1,218 ms |
| コンパイル使用メモリ | 115,580 KB |
| 最終ジャッジ日時 | 2025-01-13 03:23:12 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef __int128_t ll;
typedef long double ld;
using namespace std;
ll gcd(ll a, ll b){
if(b<a) swap(a, b);
ll r = a % b;
if(r==0) return b;
while(r!=0) r = a % b, a = b, b = r;
return a;
}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
vll extgcd(ll a, ll b) {
ll x, y;
for (ll u = y = 1, v = x = 0; a;) {
ll q = b / a;
swap(x -= q * u, u);
swap(y -= q * v, v);
swap(b -= q * a, a);
}
return vll{x, y, b};
}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = std::end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = std::end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(std::ios_base::badbit);
}
}
return dest;
}
int main() {
ll a, b, c;
long long int A, B, C;std::cin >> A >> B >> C;
a = A, b = B, c = C;
ll ans = (a-1)/b + (a-1)/c + 1 - (a-1)/lcm(b, c);
std::cout << ans << '\n';
}
tonegawa