結果
| 問題 |
No.894 二種類のバス
|
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2019-09-27 22:09:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,460 bytes |
| コンパイル時間 | 2,659 ms |
| コンパイル使用メモリ | 209,668 KB |
| 最終ジャッジ日時 | 2025-01-07 19:25:39 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
int k;
int m=0;
x=0;
for(;;){
k = getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline void wt_L(char a){
putchar_unlocked(a);
}
inline void wt_L(long long x){
int s=0;
int m=0;
char f[20];
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
putchar_unlocked('-');
}
while(s--){
putchar_unlocked(f[s]+'0');
}
}
template<class T> inline T GCD_L(T a,T b){
T r;
while(a){
r=b;
b=a;
a=r%a;
}
return b;
}
template<class S, class T> inline S divup_L(S a, T b){
return (a+b-1)/b;
}
long long T;
long long A ;
long long B;
int main(){
long long g;
long long res;
rd(T);
rd(A);
rd(B);
g =GCD_L(A, B);
res =divup_L(T,A)+divup_L(T,B);
if( (double)A/g*B < 2*T ){
res -=divup_L(T,(A/g*B));
}
else{
res--;
}
wt_L(res);
wt_L('\n');
return 0;
}
// cLay varsion 20190925-1
// --- original code ---
// ll T, A ,B;
// {
// ll g, res;
// rd(T,A,B);
// g = gcd(A,B);
// res = T /+ A + T /+ B;
// if( (double)A/g*B < 2*T ) res -= T /+ (A/g*B);
// else res--;
// wt(res);
// }
LayCurse