結果

問題 No.894 二種類のバス
ユーザー yassansannyassansann
提出日時 2019-09-27 23:15:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 549 bytes
コンパイル時間 1,287 ms
コンパイル使用メモリ 159,756 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 06:19:05
合計ジャッジ時間 2,057 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long int gcd(long long int,long long int);

int main(){
	long long int T,A,B,C,a=0,b=0,t=0,temp,ans=0;
	cin >> T >> A >> B;
	ans+=(T+A-1)/A;
	ans+=(T+B-1)/B;
	temp=A;
	while(A>=10){A/=10;a++;}
	A=temp;
	temp=B;
	while(B>=10){B/=10;b++;}
	B=temp;
	temp=T;
	while(T>=10){T/=10;t++;}
	T=temp;
	if(a+b<=t){
		C=(A*B/(gcd(A,B)));
		ans-=(T+C-1)/C;
	}else{
		ans--;
	}
	cout << ans << endl;
	return 0;
}
long long int gcd(long long int a,long long int b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
0