結果
問題 | No.894 二種類のバス |
ユーザー |
|
提出日時 | 2019-09-27 21:31:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,002 bytes |
コンパイル時間 | 1,021 ms |
コンパイル使用メモリ | 114,980 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 20:50:39 |
合計ジャッジ時間 | 1,629 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#define _USE_MATH_DEFINES#include <cstdio>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <algorithm>#include <cmath>#include <complex>#include <string>#include <vector>#include <array>#include <list>#include <queue>#include <stack>#include <set>#include <map>#include <bitset>#include <numeric>#include <limits>#include <climits>#include <cfloat>#include <functional>#include <iterator>#include <memory>#include <regex>using namespace std;long long gcd(long long a, long long b){while(b != 0){long long tmp = a % b;a = b;b = tmp;}return a;}long long lcm(long long a, long long b){long long g = gcd(a, b);if(a / g <= LLONG_MAX / b)return a / g * b;elsereturn LLONG_MAX;}int main(){long long t, a, b;cin >> t >> a >> b;-- t;long long c = lcm(a, b);long long ans = t / a + t / b - t / c + 1;cout << ans << endl;return 0;}