結果
問題 | No.894 二種類のバス |
ユーザー |
![]() |
提出日時 | 2019-09-27 22:14:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 667 bytes |
コンパイル時間 | 1,500 ms |
コンパイル使用メモリ | 167,580 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 16:47:12 |
合計ジャッジ時間 | 2,209 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll mod = 1000000007;const ll INF = mod * mod;#define rep(i,n) for(int i=0;i<n;i++)#define per(i,n) for(int i=n-1;i>=0;i--)#define Rep(i,sta,n) for(int i=sta;i<n;i++)#define rep1(i,n) for(int i=1;i<=n;i++)#define per1(i,n) for(int i=n;i>=1;i--)#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)ll gcd(ll a, ll b){if (a==0) return b;else if (b==0) return a;else if (a>b) return gcd(b, a%b);else return gcd(a, b%a);}int main(){ll T, A, B; cin >> T >> A >> B;ll ans = (T-1)/A + (T-1)/B - (T-1) / A * gcd(A,B) / B + 1;cout << ans << endl;}